林試圖發送一個API一個asp.net UTC時間戳是這樣的:Momentjs UTC時間是古怪
d = new Date()
test = moment(d).utc().valueOf()
test2 = moment(d).utc().format("ZZ")
utc_asp = "/Date("+test+test2+")/"
console.log utc_asp
>> /Date(1372670700799+0000)/
但服務器獲取的時間是一樣的本地時間?
或者這樣:
console.log moment(d)
console.log moment(d).utc()
D {_i: Mon Jul 01 2013 11:26:10 GMT+0200 (SAST), _f: undefined, _l: undefined, _isUTC: false, _d: Mon Jul 01 2013 11:26:10 GMT+0200 (SAST)…}
index.js:39
D {_i: Mon Jul 01 2013 11:26:10 GMT+0200 (SAST), _f: undefined, _l: undefined, _isUTC: true, _d: Mon Jul 01 2013 11:26:10 GMT+0200 (SAST)…}
這樣做:
console.log moment(now).utc().hour()
>> 9 - This is correct! Its 11 - 2, but how come the above
我這樣做是不正確的?
我有類似的問題。無法獲取本地時間戳,並將其轉換爲UTC轉換爲javascript日期格式。你能解決嗎? – Cmag