美文网首页
人类时间格式与时间戳

人类时间格式与时间戳

作者: jebirth | 来源:发表于2018-01-20 02:29 被阅读0次


人类时间格式

使用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=

相关文章

网友评论

      本文标题:人类时间格式与时间戳

      本文链接:https://www.haomeiwen.com/subject/epszoxtx.html