
人类时间格式
使用moment.js获取,如下所示:
const CurrentDate = moment();
console.log(CurrentDate); //moment("2018-01-20T02:23:37.399")
设置时间的格式,如下所示:
const CurrentDate = moment().format("MM/DD/YYYY");
console.log(CurrentDate); //'01/20/2018'
时间戳
获取当前的时间戳,如下所示:
const CurrentDate = moment().unix();
console.log(CurrentDate); //1516386318
将时间戳转换为当前时间,如下所示:
const time = moment().unix();
console.log(moment.unix(time).format("MM/DD/YYYY")) ;
参考网站:aHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvMjU3MzQ3NDMvbW9tZW50LWpzLXJldHVybi10aGUtY3VycmVudC10aW1lc3RhbXA=
网友评论