Reputation: 307
in my ASP.net application, in the js, i got the date format as '2017-04-26T09:00:00Z'. What is this format? And when i return this to the view page, the date is changed to 26/04/2017 02:00 am. But the actual time is 09.00 am. Kindly help me why this is happening? My js code is
{
"data": "Date",
"render": function (data) {
return moment(data).format('MM/DD/YYYY H:m');
}
}
Upvotes: 1
Views: 965
Reputation: 2719
Based on W3scholls :
And if you test this link you will be get the secret behind this.
Upvotes: 1
Reputation: 2469
The date you see in the JS is actually your the date Time with your timezone. On server side it will automatically get converted to the UTC timezone.
you must be at UTC + 7:00Hrs time zone right.
If you want to get the Date right just strip the Time part in JS,
moment(data).format('MM/DD/YYYY');
Upvotes: -1
Reputation: 653
'Z' stands for Zulu time, which is also GMT and UTC.
moment is converting that timestamp (your variable data) to your local timezone which appears to be 7 hours behind GMT.
Upvotes: 4