The Date Timezone Problem
You'll learn why JavaScript's Date object always operates in the browser's local timezone and how this creates unexpected behavior in web applications.
The Core Issue
JavaScript's Date object doesn't truly store timezone information—it only stores a single timestamp (milliseconds since Unix epoch). However, whenever you display or manipulate a Date, JavaScript automatically interprets it in the user's local timezone.
This creates a fundamental problem: the same Date object shows different values to users in different locations.
Why This Matters
Imagine you're building a scheduling app. You create an event for "January 15, 2025 at 10:00 AM" and store it as a Date object. A user in New York creates this event, and their browser creates the date in EST. When a user in Tokyo views that same stored date, their browser displays it in JST—showing a completely different time!
Even worse: if you send a date to your server or store it in a database, the conversion between local time and the stored timestamp can cause the date to "shift" unexpectedly.
The Pitfalls
// User in New York creates this
const meeting = new Date('2025-01-15T10:00:00');
// Sends to server, gets converted to UTC
// Might become "2025-01-15T15:00:00Z"
// User in Tokyo retrieves it
// Sees "2025-01-16T00:00:00" — wrong day!
The date appears to change because Date has no concept of "this event happens at 10 AM regardless of timezone." It only knows absolute moments in time.
Key Takeaway: JavaScript Date objects always use the browser's local timezone for display and manipulation, making them unreliable for timezone-sensitive applications without careful UTC handling or a proper date library.