I have set up a JSON endpoint that returns the current time from server. For example:
{
"myservertime": "2011-10-02T23:00+02:00"
}
So this is the CET summer time right now.
Now, I also have a jQuery code that parses that very well.
$.sysTime = function(success) {
$.ajax({
url: '/jsontimepath/',
dataType: 'json',
async: false,
success: function(json){
sysDateTime = new Date(Date.parse(json.myservertime));
console.log('The system time now is: ' + sysDateTime)
}
});
return sysDateTime;
};
The problem is that when I check the console, it still shows wrong time... It is still affected by the timezone of my computer... For example, for a user in Hong Kong, the time quoted above would result:
Mon Oct 03 2011 05:00:00 GMT+0800 (HKT)
I do give it a valid ISO8601 time string and it just adjusts it. The actual time that is returned is correct (in that timezone)... But why does it adjust it like that??? I want it to return CET time not the local time...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…