Time makes fools of us all, and JavaScript is no slouch in that department either. Honestly, I’ve never minded the latter much — in fact, if you’ve taken JavaScript for Everyone or tuned into the newsletter, you already know that I largely enjoy JavaScript’s little quirks, believe it or not.
I like when you can see the seams; I like how, for as formal and iron-clad as the ES-262 specification might seem, you can still see all the good and bad decisions made by the hundreds of people who’ve been building the language in mid-flight, if you know where to look. JavaScript has character. Sure, it doesn’t necessarily do everything exactly the way one might expect, but y’know, if you ask me, JavaScript has a real charm once you get to know it!
There’s one part of the language where that immediately falls apart for me, though.
Code language js Copy to clipboard console . log ( new Date ( 2026 , 1 , 1 ) ) ;
The Date constructor.
Code language js Copy to clipboard console . log ( new Date ( "49" ) ) ; console . log ( new Date ( "99" ) ) ; console . log ( new Date ( "100" ) ) ;
I dislike Date immensely.
Code language js Copy to clipboard console . log ( new Date ( "2026/1/2" ) ) ; console . log ( new Date ( "2026/02/2" ) ) ; console . log ( new Date ( "2026-02-2" ) ) ; console . log ( new Date ( '2026/01/02' ) ) ; console . log ( new Date ( '2026-01-02' ) ) ;
Date sucks. It was hastily and shamelessly copied off of Java’s homework in the car on the way to school and it got all the same answers wrong, right down to the name at the top of the page: Date doesn’t represent a date, it represents a time. Internally, dates are stored as number values called time values: Unix timestamps, divided into 1,000 milliseconds — which, okay, yes, a Unix time does also necessarily imply a date, sure, but still: Date represents a time, from which you can infer a date. Gross.
Code language js Copy to clipboard const timestamp = 818053200 ; console . log ( new Date ( timestamp * 1000 ) ) ;
... continue reading