Hasty Briefsbeta

Bilingual

When JavaScript Decided My Day Starts at 9AM

9 months ago
  • #JavaScript
  • #Date Handling
  • #Time Zones
  • new Date('2000-01-01') creates a date at midnight UTC, not local time.
  • In Japan (UTC+9), this results in 2000-01-01T09:00:00, causing dashboard filters to miss data before 9AM.
  • The bug occurred because the Date constructor assumed UTC, leading to incorrect comparisons.
  • The fix involves explicitly setting the time to midnight local time and adjusting the max date range.
  • Lessons include being cautious with date string interpretations and preferring explicit time settings.