伙计们,
我正在尝试理解MomentJS API。获取机器上当前时间的适当方法是什么?
var CurrentDate = moment();
vs
var CurrentDate = moment().format();
试图解析他们的文档,它不明显使用什么。
http://momentjs.com/docs/#/query/is-a-moment/
伙计们,
我正在尝试理解MomentJS API。获取机器上当前时间的适当方法是什么?
var CurrentDate = moment();
vs
var CurrentDate = moment().format();
试图解析他们的文档,它不明显使用什么。
http://momentjs.com/docs/#/query/is-a-moment/
当前回答
试着这样使用它:
let current_time = moment().format("HH:mm")
其他回答
对于任何使用反应时刻的人:
import Moment from 'react-moment'
内部渲染(使用你需要的格式道具):
const now = new Date()
<Moment format="MM/DD/YYYY">{now}</Moment>
试着这样使用它:
let current_time = moment().format("HH:mm")
如果您只想要从01-JAN-1970年开始的毫秒数,那么您可以使用
var theMoment = moment(); // or whatever your moment instance is
var millis;
millis = +theMoment; // a short but not very readable form
// or
millis = theMoment.valueOf();
// or (almost sure not as efficient as above)
millis = theMoment.toDate().getTime();
地点:
moment.locale('pt-br')
return moment().format('DD/MM/YYYY HH:mm:ss')
当前日期使用moment .js,格式为DD-MM-YYYY
const currentdate=moment().format("DD-MM-YYYY");
console.log(currentdate)