In javascript Date.parse('2015-04-02')
returns 1427932800000
which is the same result as Date.parse('2015-04-02 03:00:00')
, what can explain this behaviour?
Asked
Active
Viewed 76 times
0

constant.oduol
- 25
- 5
-
1I'd guess UTC and your local time zone. – Omri Aharon Apr 02 '15 at 08:14
-
`Date.parse('2015-04-02')` returns `1427932800000` and `Date.parse('2015-04-02 03:00:00')` returns `1427923800000` for me. Definitely, your timezone would be +3:00. – Jashwant Apr 02 '15 at 08:16
-
possible duplicate of [javascript Date.parse](http://stackoverflow.com/questions/2587345/javascript-date-parse) – JJJ Apr 02 '15 at 08:16
-
yeah my time zone is UTC+3 – constant.oduol Apr 02 '15 at 08:16
1 Answers
0
The Date depends on your local timezone. but the returned number is un UTC. if you want to convert you can do (I think) :
var date = new Date('2015-04-02 03:00:00')
date.setMinutes(-date.getTimezoneOffset())

DARK_DUCK
- 1,727
- 2
- 12
- 22
-
BTW be careful using the "-" separator it is not recognized by firefox – DARK_DUCK Apr 02 '15 at 08:19
-
-
-
I changed the code, you should try. It worked with my timezone (UTC+1) – DARK_DUCK Apr 02 '15 at 08:35
-
i think it should be +date.getTimezoneOffset() to return it to 2015-04-02 00:00:00 – constant.oduol Apr 02 '15 at 09:33