【发布时间】:2017-02-06 10:38:39
【问题描述】:
var utcMilliSeconds = 1486116995814;
// UTC time:03/02/2017 10:16:35 (From epoch Converter)
// IST time:03/02/2017, 15:46:35 (From epoch converter)
moment.utc(1486116995814).local().format("DD/MM/YYYY HH:MM:ss"); //IST time:03/02/2017 15:02:35 but it's wrong
moment.utc(1486116995814).toDate(); //Fri Feb 03 2017 15:46:35 GMT+0530 (India Standard Time)
toDate() 给出正确的时间,但我不想使用 toDate(),因为 JavaScript 日期格式不灵活。
moment.local() 有什么问题,为什么它没有给出准确的时间,有没有简单的方法将 UTC 毫秒转换为浏览器的时间而不使用任何其他库?
【问题讨论】:
标签: javascript momentjs