Thank Java for Better JavaScript Dates
I gave a lightning talk at NebraskaJS about the complex, decades-long relationship between JavaScript and Java's Date APIs:
The first half was a bit of a troll; I used a Java REPL (anonymized to look like Node) to demonstrate some of the more famously unexpected behavior in the Date
class:
var date = new Date("March 20 2025");
date.getMonth(); // returns 2
date.getDay(); // returns 3
date.getYear(); // returns 125??
This code is syntactically correct Java and JavaScript, and behaves identically in both languages. One of the gifts of being told to "make it like Java" when adding dates to a ten-day-old language.
Java, of course, got markedly improved Date/Time APIs in version 8. Spearheaded by the lead developer of the de facto third-party date/time library, the java.time
APIs were a breath of fresh air, and the new standard tool for all time-related matters.
JavaScript has been following the same path, with Maggie Pint (one of the maintainers of Moment.js) working to standardize the Temporal API. It's been a long journey, with it reaching Stage 3 of the TC39 process way back in 2021, but hasn't made its way to a browser engine just yet.
But it's finally making its way into browsers! Safari, Firefox, and Deno have it in preview release, with Chromium browsers in active development.
So it's a great time to refamiliarize yourself with the API, start checking out the polyfill, and start building fun stuff, like my gravel racing time estimator.
- Thank Java for Better JavaScript Dates - 2025
- This blog's comments are powered by Webmentions - 2025
- From Gatsby to Eleventy - 2024
- Mutation Testing with StrykerJS - 2024
- My favorite water bottles - 2024
- Web Push is almost usable with iOS 17 - 2023
- I wired up my bike's GPS to order me pizza during a gravel race 🍕 - 2023
- Running a Playwright script on AWS Lambda - 2023
- Overly Complicate Starting Your Vehicle, Using Home Assistant, an ESP8266, and a Spare Car Fob - 2023
- Generating Custom OpenGraph Cards with Gatsby and the 11ty Screenshot Service - 2023
- Keeping your Fediverse followers when moving Owncast servers - 2023
- Running Owncast with Hardware Acceleration on a Raspberry Pi 4 - 2023
- Vite is Neat - 2023
- Serverless Bike Tracking with a SPOT Tracker, AWS Location + Friends - 2022
- Advent of Code as Soulcraft - 2021
- Gravel Worlds - Long Voyage - 2021
- Making a Raspberry Pi Photo Booth with Pibooth, NeoPixels, and Giant Buttons - 2021
- 3 Things I Learned Trying out the JavaScript Temporal API - 2021
- Green Screen Zwifting with retroreflective fabric - 2021
- Getting the PPPoE Credentials from your C4000XG without calling CenturyLink - 2020
- Setting up a Livestream with Owncast - 2020
- Indieweb Livestreaming your Wedding with Owncast - 2020
- Maybe mashups in 2020 are just Jamstack sites - 2020
- Secret Strava - 2020
- <bt-device> and Renderless Web Components - 2020
- Building Fast, Tiny GitHub Actions with Go and Docker - 2019
- Why I Built Blumhouse to Purge My Twitter History - 2019
- Toolchainless - 2019
- Web Components Aren't Weird Anymore - 2018
- JavaScript Gardening with the Particle Photon - 2018
- The Neverending Side Project - 2018
- Light Up Your Bike with Web Bluetooth and StencilJS - 2017
- Every Java Developer Should Learn TypeScript - 2017
- Web Bluetooth Is Your New Squeeze - 2017
- Building Custom Elements That Work With AngularJS 1.x and Angular - 2016
- How to Run a Board Game Library At Your Conference After-Party - 2016
- The Languages Which Almost Became CSS (Recap) - 2016
- Upgrading to Angular 2 using ngUpgrade - 2016
- Reacting to Heart Rate and Bike Sensors With RxJS - 2016
- Driving an LED Light Strip with Heart Rate and Bike Sensors - 2015
- Bringing ArnoldC to JavaScript - 2015
- Source Maps in 2015 - 2015
- We're hosting a JavaScript conference! - 2015
- Building a Handcrafted IR Blaster for Arduino-Powered Bike Lights - 2014
- Responsive Images using <picture> and srcset/sizes - 2014
- Responsive Web Design Workshop at Interface - 2014
- Hardware is the new Geocities - 2014
- Go(lang) for Broke - 2013
- Clickbait HTTP Status Codes - 2013
- A fresh coat of paint - 2013
- Exploring the Device APIs - 2013
- Diving into the Device API - 2013
- Unit Testing JavaScript when you're Afraid of JavaScript - 2013
- What Zelda Taught Me About Front End Engineering - 2012
- Unit Testing in JavaScript with Jasmine - 2012
- Town Tester - How well does your city unit test? - 2012
- Zen and the Art of TDD - 2012
- Lessons Learned from the first Hack Omaha - 2012
- I have a cameo in The Clean Coder - 2011
- Test-driven source code formatting - 2011
- Scramble Squares puzzle game solver - 2010
- Omaha Public Library card symbology - 2010
- Now this is a story all about how my bike got flipped, turned upside down - 2009
- The King of Kong - A Fistful of Inaccuracies - 2008
- Inelegant code affects your reputation - 2008
- Unintended consequences of the Internet - 2007
- Screen scraping Google Spreadsheets exported as HTML - 2007
- UI designs in Leopard that I really hope grow on me - 2007
- The Thatcher Illusion - 2007