frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

New Date("wtf") – How well do you know JavaScript's Date class?

https://jsdate.wtf
69•OuterVale•2h ago

Comments

schoen•1h ago
Lots of surprises here! The general theme seems to be that the parser is very eager to find some interpretation of the input as a date, even in ways that appear pretty unprincipled, even in circumstances where human users would probably not agree with the interpretation, and even though it does have ways that it could signal errors. Though maybe some of the weird cases actually do trace back to unusual real-world use cases!
4ndrewl•1h ago
Related: https://www.destroyallsoftware.com/talks/wat
leipert•1h ago
10/28. Not bad. But probably also is implementation dependent: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
samwho•1h ago
It very much is. I put the lil notice at the start that I verified the questions on a specific version of Node, with a specific timezone, because both things matter.
zinekeller•48m ago
Some notes that I have noticed. First, why does it seem that the V8 date parser is heavily inspired by the Windows date parser (https://devblogs.microsoft.com/oldnewthing/20200304-00/?p=10...)? EDIT: Apparently not, "new Date('Savvyday 29 Oatmeal 94')" is invalid both in Firefox and Chrome.

Second, I opened this in Firefox with the console open to answer these questions, and found these divergences (to summarize, Firefox is strict):

Question 14:

  new Date("12.1")
> "12.1" is interpreted as the date December 1st, and as before for dates with no year the default is 2001 because of course.

Firefox returns an Invalid Date object instead.

Question 16:

  new Date("12.-1")
> The dash here is ignored, so this is interpreted the same as "12.1".

Again, Firefox returns an Invalid Date object instead.

Question 19:

  new Date("maybe 1")
> "may" in "maybe" is parsed as the month May! And for some reason this expression cares about your local timezone, which happens to be BST for me right now.

Seems a broken record, but this is still an Invalid Date for Firefox.

Question 20:

  new Date("fourth of may 2010")
> "fourth of" is ignored, this is just parsing "may 2010" and again local timezone is important.

Ibid in Firefox.

Question 21:

  new Date("May 4 UTC")
> UTC is correctly parsed as a timezone.

No, Firefox is still not accepting this one.

Question 22:

  new Date("May 4 UTC+1")
> You can add modifiers to timezones and it works as you would expect.

Neither this one.

Question 23:

  new Date("May 4 UTC+1:59")
> It also supports minutes!

Firefox: Not really.

Final note: It parses Question 24 as you expect in Firefox. Which honestly, it shouldn't!

samwho•46m ago
Yeah, as I understand it this isn’t backed by any spec. I decided to go with Node’s (v8’s) implementation for the quiz. Fun to see how much divergence there is!
mnahkies•8m ago
It's probably improved the past 8 years or so, but I remember Safari was particularly bad for bugs around DST and just dates in general back then, even when using valid input.

We ended up with a bunch of Safari specific workarounds that weren't necessary on Chrome (it was mostly a webview use case so Safari and Chrome were the two we cared about at the time)

Assumingly to me this was around the same time that Apple seemed to have DST problems more generally, such as their iOS alarm clock mishap https://www.theguardian.com/technology/blog/2010/nov/01/ipho...

mcv•35m ago
I'm not sure if I should be pleased or embarrassed about my 17/28. Why do I even know this?

My son was pretty happy with his 11/28 without any experience with js Date. Just deduced it from previous answers. And I explained type coercion to him.

I now realize I may have put him off a career in IT.

croes•1h ago
Why?
samwho•1h ago
I discovered the 0/“0” disparity in work this week for the first time. Then I tried “1” and “2” and knew there was fun to be had. :)
worble•1h ago
So... any browser other than Firefox feel like shipping Temporal yet?
bubblebeard•1h ago
Haha that was fun :D

Thanks!

torlok•1h ago
Always fun to click through JS quizzes for the laughs. I've been programming JS since over a decade, and I never dared to use Date to parse anything I didn't verify with a regex.
KaiMagnus•1h ago
12/28, could've gotten a few more by thinking harder, but I was getting so annoyed that I didn't want to, great job!
bsmth•53m ago
Post by the author Sam Rose about it: https://bsky.app/profile/samwho.dev/post/3ltpdkr3bmk2o
samwho•46m ago
It me.
bsmth•39m ago
Oh hi! Thanks for the great quiz
sankalpmukim•46m ago
9/28 - This was very good fun. Can't believe so much of the world's (important?) software is written in this toy language.
ilovethe80s•42m ago
JavaScript has survived because it must be backwards compatible, not because it ever made sense.

Adding Temporal will only add to the chaos. Now there will be Date, moment, Luxon’s objects, and Temporal. See??? We fixed it!!!

mcv•36m ago
Too many standards? Time to add another one. This one will be final, I promise.
mnahkies•40m ago
It's a fun quiz, and there's a lot of surprising behaviour. However in my opinion from a practical perspective it mostly doesn't matter.

Think hard about whether your use case really cares about local time, try and find ways to make instants appropriate. Then stick to UTC ISO 8601 strings / Unix timestamps and most of the complexity goes away, or at least gets contained to a small part of your software.

I know this isn't always possible (I once had to support a feature that required the user took a break covering two periods of 1-5am local, which was obviously fun around DST boundaries) - but in my experience at least the majority of the time you can find ways to minimise the surface area that cares.

If you're passing raw/unvalidated user input to the date parser you're holding it wrong.

samwho•35m ago
I agree with this. I do think it’s an easy trap to fall into if you’re unfamiliar, and hopefully this quiz has made a whole wave of folks more familiar. :)
BrandoElFollito•35m ago
This is one of the reasons that I, an amateur dev, never touch dates other than via date-fns or other date libs.

Dates and times are insane, no matter the language.

hidroto•27m ago
4 / 28 "You would have scored higher by guessing at random."

I think my strategy for JavaScript going forward is to 'drop & run'.

norskeld•21m ago
Scored 17/28. Thank you, this is absolutely cursed! It's probably a good time to go and check out the Temporal stuff (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...).
wiseowise•9m ago
Cute. But things like these have tendency to be abused by “haha, js” crowd even if those things are irrelevant in practice.
nikolayasdf123•8m ago
someone should make one for Python based on https://github.com/satwikkansal/wtfpython
LoganDark•7m ago
I just fixed a bug at work where JS Date was parsing arbitrarily long strings as random date values just because they happened to contain an integer anywhere in the string. Madness.

How I Make Personalised Mini Magazines at Home

https://blog.decryption.net.au/posts/booklets.html
1•k2enemy•2m ago•0 comments

Nvidia Unveils Helix Parallelism Enabling 32x Faster AI Inference

https://www.storagereview.com/news/nvidia-unveils-helix-parallelism-enabling-32x-faster-ai-inference-with-multi-million-token-contexts
1•rbanffy•4m ago•0 comments

Russian Developers Urge Ban on Microsoft Windows for School Exams

https://www.themoscowtimes.com/2025/07/11/russian-developers-urge-ban-on-microsoft-windows-for-school-exams-a89785
1•amai•7m ago•0 comments

Fault Tolerant Quantum Computing: Quantinuum's Advance

https://spectrum.ieee.org/quantinuum-fault-tolerant-quantum-computing
1•rbanffy•9m ago•0 comments

Running a million-board chess MMO in a single process

https://eieio.games/blog/a-million-realtime-chess-boards-in-a-single-process/
1•isaiahwp•11m ago•0 comments

Ask HN: How do free (illegitimate) streaming apps cover running costs?

2•BuildTheRobots•13m ago•1 comments

Sizing Up AWS "Blackwell" GPU Systems Against Prior GPUs and Trainiums

https://www.nextplatform.com/2025/07/10/sizing-up-aws-blackwell-gpu-systems-against-prior-gpus-and-trainiums/
1•rbanffy•14m ago•0 comments

ML researchers, let's solve hardware engineering

1•MRiabov•16m ago•0 comments

AI for Good [Appearance?]

https://aial.ie/blog/2025-ai-for-good-summit/
1•NotInOurNames•16m ago•0 comments

Looks like 1,300 Indeed and Glassdoor staffers will need their former employer

https://www.theregister.com/2025/07/12/indeed_glassdoor_layoffs/
1•rntn•19m ago•0 comments

Air India 171 Update: Fuel Cutoff Switches in 'Cutoff' Position per WSJ [video]

https://www.youtube.com/watch?v=MD64uYK926o
1•mastazi•20m ago•0 comments

Research team produces low-loss spin waveguide network

https://www.uni-muenster.de/news/view.php?cmdid=14852&lang=en
1•doener•22m ago•0 comments

Show HN: I made a game which forces me to workout (do a chin-up, save a cat)

https://old.reddit.com/r/webdev/comments/1lxwx73/do_a_chinup_save_a_cat_im_building_a_workout_game/
1•getToTheChopin•27m ago•0 comments

Detained immigrants say there are worms in food and wastewater on the floor

https://apnews.com/article/alligator-alcatraz-immigration-detainees-florida-cc2fb9e34e760a50e97f13fe59cbf075
1•perihelions•28m ago•0 comments

Revival: There appears to be media consensus: "Bluesky is dead."

https://netwars.pelicancrossing.net/2025/06/27/revival/
14•ColinWright•28m ago•4 comments

Powerhouse Fruits and Vegetables: A Nutrient Density Approach

https://www.cdc.gov/pcd/issues/2014/13_0390.htm
3•Dowwie•31m ago•0 comments

Dyeing to Get In

https://www.genuineideas.com/ArticlesIndex/dye.html
2•orlp•34m ago•0 comments

YouTuber warns of Bambu Lab scam

https://3dprintingindustry.com/news/youtuber-warns-of-bambu-lab-scam-241530/
2•bookofjoe•40m ago•0 comments

Meet me here on "Savvyday 29 Oatmeal 94" (2020)

https://devblogs.microsoft.com/oldnewthing/20200304-00/?p=103527
2•zinekeller•42m ago•0 comments

We made Cursor generate full admin panels with 7 inputs

https://dev.family/blog/article/integrating-cursorrules-into-admiral-for-faster-admin-panel-development
1•dev_family•42m ago•1 comments

Calculate time to crack a cryptographic key (web tool)

https://bruteforce.bitsnbites.eu/
1•mbitsnbites•47m ago•0 comments

How AI on Microcontrollers Actually Works: The Computation Graph

https://danielmangum.com/posts/ai-microcontrollers-computation-graph/
1•hasheddan•52m ago•0 comments

Grok July 8 incident analysis (X)

https://twitter.com/grok/status/1943916977481036128
3•mellosouls•53m ago•1 comments

CIAM vs. IAM – Customer Identity vs. Identity Access Management Explained

https://fusionauth.io/articles/ciam/ciam-vs-iam
1•mooreds•53m ago•0 comments

OpenAI to release web browser in challenge to Google Chrome

https://www.cnbc.com/2025/07/09/openai-to-release-web-browser-in-challenge-to-google-chrome.html
17•mooreds•54m ago•16 comments

Behold These Hidden Galaxies

https://nautil.us/behold-these-hidden-galaxies-1223749/
1•dnetesn•55m ago•0 comments

Valve solved the attention problem using hardcore gamers who love a fat backlog

https://www.gamesradar.com/games/valve-cracked-the-problem-that-netflix-was-struggling-with-using-diehard-gamers-and-their-backlogs-steam-expert-says-you-get-access-to-a-bunch-of-drunken-sailors-who-spend-money-irresponsibly/
2•jakubmazanec•55m ago•0 comments

ICANN fumes as AFRINIC offers no explanation for annulled election

https://www.theregister.com/2025/07/11/afrinic_election_annulled_why/
15•rntn•57m ago•0 comments

The Past Is a Ghost and the Future a Fantasy

https://nautil.us/the-past-is-a-ghost-and-the-future-a-fantasy-1221672/
1•dnetesn•58m ago•0 comments

The Danger of a Market Melt-Up

https://www.nytimes.com/2025/07/11/business/stock-market-melt-up-downturn.html
1•mooreds•58m ago•0 comments