The JavaScript Date Playground is a quick way to see how Date parses, stores, and formats a value in the current browser. Use it when a timestamp looks plausible but behaves differently from the surrounding code.

Good experiments to run

  • Compare new Date(1700000000) with new Date(1700000000 * 1000).
  • Format one instant in UTC and in a named IANA timezone.
  • Compare a date-only string with a date-time string that has no timezone offset.
  • Inspect getTime(), toISOString(), and locale formatting separately.

Date stores a single millisecond value. The trouble usually begins at input and display boundaries: a missing offset, a seconds-versus-milliseconds mix-up, or an implicit local timezone. The playground makes those choices explicit in a safe place.

Frequent questions:

Q: Why is getMonth() zero-indexed in JavaScript?
A: JavaScript's Date.getMonth() returns 0 for January and 11 for December. This design decision was inherited from Java's java.util.Date class in the 1990s. Always add 1 when displaying the month to users: date.getMonth() + 1.
Q: What is the difference between new Date('2024-01-01') and new Date('2024/01/01')?
A: new Date('2024-01-01') uses ISO 8601 format and is parsed as UTC midnight (00:00:00Z). new Date('2024/01/01') uses a non-standard format that most browsers parse as local midnight in your timezone. Always use ISO 8601 with an explicit timezone offset for predictable behavior.
Q: How do I format a Date in a specific timezone without an external library?
A: Use the built-in Intl.DateTimeFormat API: new Intl.DateTimeFormat('en-US', { timeZone: 'America/New_York', dateStyle: 'full', timeStyle: 'long' }).format(date). This is supported in all modern browsers and Node.js 13+.