var end, moment, timeFormat;
moment = require('moment');
end = moment.utc('2016-11-29T23:59:59.999');
console.dir(end.format());
timeFormat = 'YYYY-MM-DDThh:mm:ss.SSS';
console.dir(end.format(timeFormat));
輸出:如何獲取moment.js以毫秒爲單位輸出UTC時間的格式化時間?
'2016-11-29T23:59:59Z'
'2016-11-29T11:59:59.999'
我真正需要的:
'2016-11-29T23:59:59.999'
爲什麼會出現這些2個輸出之間有12小時的時差?我可以只增加12個小時,但這是hacky。我不明白爲什麼在我給它一個格式之後,突然從我的約會中減去12個小時。似乎不太可能這是一個錯誤;我更可能誤解Moment正在做的事情。
我的時區是格林威治標準時間+8。
因爲你正在使用'hh'(0-12),而不是'HH'(0-23),參見['格式( )'](http://momentjs.com/docs/#/displaying/format/)文檔。 – VincenzoC