Reputation: 1
I am trying to convert in a custom date format in IE9 of Windows 7 version but the date.getUTCDate()
reuturns previous day's date. I have attached the Sample JS Fiddle.
//'Tue Apr 25 00:00:00 UTC+0530 2013'
var date = new Date('Tue Apr 25 00:00:00 UTC+0530 2013');
document.write(
(date.getUTCMonth() + 1) + "/" +
date.getUTCDate() + "/" +
date.getUTCFullYear()
);
JS Fiddle : http://jsfiddle.net/QzKwE/67
Upvotes: 0
Views: 64
Reputation: 136104
A time of midnight in a timezone which is UTC+530
converted to UTC time will indeed be on the previous day.
This is exactly what it is supposed to do. In fact, changing your fiddle to output the entire date and time in UTC reveals the detail:
input:
Tue Apr 25 00:00:00 UTC+0530 2013
output:
Wed, 24 Apr 2013 18:30:00 GMT
5h30m before midnight on the input date.
Upvotes: 2