我正在尝试将日期字符串转换为纪元,然后将纪元返回日期字符串以验证我是否提供了正确的日期字符串。
var epoch = moment("10/15/2014 9:00").unix(); // do I need to do .local()?
var momentDate = moment(epoch); // I've also tried moment.utc(epoch)
var momentDateStr = momentDate.calendar();
alert("Values are: epoch = " + epoch + ", momentDateStr = " + momentDateStr);
渲染器
Values are: epoch = 1413378000, momentDateStr = 01/17/1970
注意:我正在使用以下版本的瞬间js脚本,//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment-with-locales.js