我是否錯誤地實現了setUTCMilliseconds?對於我輸入的任何值,我都會得到錯誤的日期。下面只是一個錯誤值的例子。我所有的測試數據都是在JS中的5月24日(未來的未來)解決,但在C#或使用快速在線轉換工具中,我的UTS MS是正確的。javascript setUTCMilliseconds是錯誤的?否則,我錯了
有什麼想法?
function parseDate(epoch) {
var d = new Date();
//tried this too, but it shows me the actual epoch 1970 date instead
//var d = new Date(0);
//EDIT: this should be seconds in combination with Date(0)
d.setUTCMilliseconds(parseInt(epoch));
return d.toString();
}
// 1336423503 -> Should be Mon May 07 2012 13:45:03 GMT-7
// javascript says
Thu May 24 2012 05:03:21 GMT-0700 (Pacific Daylight Time)
你傳遞的價值不是一個時代,它是自**時代以來的時間**。 – RobG
是的,我明白數字的含義。我在這裏使用它像epochtime – FlavorScape