Get the latest tech news

JavaScript decided my day starts at 9am


TL;DR: new Date('2000-01-01') creates a date at midnight UTC, not local time. In Japan (UTC+9), that means 2000-01-01T09:00:00, so our dashboard filters missed all data created before 9AM.

We noticed something strange while fetching data for an admin dashboard: records created before 9AM were missing! Instead of letting new Date() assume UTC, explicitly set it to midnight. For filters, prefer constructing with year/month/day explicitly or append a local time.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Day

Day

Photo of javascript

javascript

Related news:

News photo

Apple Offering 'Deal of the Day' Discounts in TV App

News photo

My 2.5 year old laptop can write Space Invaders in JavaScript now (GLM-4.5 Air)

News photo

Xbox's State of Decay 3 and Gears of War: E-Day heading to PS5, report claims