I am stuck in a weird situation and unfortunately, even after doing some RnD and googling, I am unable to solve this problem.
I have a date string in ISO format, like 2014-11-03T19:38:34.203Z
and i want to convert it into a date object with new Date()
method.
But when i do so, output is:
var isoDate = '2014-11-03T19:38:34.203Z';
console.log(new Date(isoDate)); //output is: Tue Nov 04 2014 01:08:34 GMT+0530 (IST)
The date which i passed is of 3 Nov,2014
and the output is 4 Nov,2014
and it's because of GMT +5.30 of our local time(IST).
So, is there any generic method with which i can get the date
object which return the date of Nov 3,2014
.
NOTE: I don't have any issues with timestamp. We can change time string to zero with setHours()
method. The only thing which i want is date
object like new Date()
having date of 3 Nov,2014
.