0
我在ASp.NET MVC中使用JSON返回數據。日期轉換爲說轉換UTC中的Epoch到當前時區日期
\\/Date(1444089473757)\
這個日期我在我的數據庫中存儲在UTC。
我想將日期轉換爲javascript中的當前日期時間對象。
我嘗試使用moment.js和其他功能,如
var date = new Date(parseInt((this.DateAdded).substr(6)));;
date = new Date(parseInt(this.DateAdded.replace("/Date(", "").replace(")/", ""), 10));
var date = new Date(0); // The 0 there is the key, which sets the date to the epoch
date.setUTCSeconds(parseInt(utcSeconds/1000));
所有創建瀏覽器的時區,而不是UTC日期。
我要的是創造一個UTC日期,所以我可以抵消到瀏覽器的時區
任何幫助表示讚賞。
沒有做這我不適合我。這是考慮myTimestamp這是UTC作爲當前時區時間戳 – Moons
我的時間戳是1444133845847需要基於當前時區日期 – Moons
好轉...那麼爲什麼不使用'新日期(1444089473757)'?這將返回與您的UTC時間戳相對應的日期對象。這個日期對象有很多方法來及時提取這個點的本地表示 –