Skip to content Skip to sidebar Skip to footer

New Date() Converts Timezone

Why is new Date() converting the timezone? I'd like my date to be the same as the string I provide, so 00:30 and not 10:30. >>> new Date('2015-04-11T00:30:00'); Sat Apr 11

Solution 1:

You passed the date in ISO form into the constructor "2015-04-11T00:30:00". That means your browser interprets that not as local time but as UTC. Date.toString however uses your local time. If you want to use UTC time call .toUTCString or better yet .toISOString.


Post a Comment for "New Date() Converts Timezone"