toDateString() decrements my date

date, javascript

Solution

The date is parsed as UTC date, but the `toDateString()` outputs what that time is in the local timezone.

Try this instead

var d = new Date(2013, 6, 1); //6 instead of 7 because the mont argument is  zero-based
console.log(d.toDateString());

What date is actually stored?

2013-07-01 00:00:00 UTC

Problem

For the following code: ``` var d = new Date("2013-07-01"); console.log(d.toDateString()); ``` It outputs Sun Jun 30 2013, which is one day less of what was input. What happened to the object? What date is actually stored?

Original source

Related problems