Javascript

The Future of Dates in JavaScript: Introducing Temporal

Ignacio Falk
2 min read
Ignacio - The Future of Dates in JavaScript: Introducing Temporal

The Future of Dates in JavaScript: Introducing Temporal

What is Temporaal?

Temporal is a proposal currently at stage 3 of the TC39 process. It's expected to revolutionize how we handle dates in JavaScript, which has always been a challenging aspect of the language.

But what does it mean that it's at stage 3 of the process?

  • The specification is complete
  • It has been reviewed
  • It's unlikely to change significantly at this point

Key Features of Temporal

Temporal introduces a new global object with a fresh API. Here are some important things to know about Temporal:

  1. All Temporal objects are immutable
  2. They're represented in local calendar systems, but can be converted
  3. Time values use 24-hour clocks
  4. Leap seconds aren't represented

Why Do We Need Temporal?

The current Date object in JavaScript has several limitations:

  • No support for time zones other than the user's local time and UTC
  • Date objects can be mutated
  • Unpredictable behavior
  • No support for calendars other than Gregorian
  • Daylight savings time issues

While some of these have workarounds, not all can be fixed with the current Date implementation.

Let's see some useful examples where Temporal will improve our lives:

Some Examples

Creating a day without a time zone is impossible using Date, it also adds time beyond the date. Temporal introduces PlainDate to overcome this.

let usingDate = new Date('2025-04-03');
// 2025-04-03T00:00:00.000Z

console.log(usingDate);
// Wed Apr 02 2025 21:00:00 GMT-0300 (Chile Summer Time)

let usingTemporal = Temporal.PlainDate.from('2025-04-03');
// PlainDate [Temporal.PlainDate] {}
console.log(usingTemporal.toString());
// 2025-04-03

But what if we want to add timezone information? Then we have ZonedDateTime for this purpose. The timezone must be added in this case, as it also allows a lot of flexibility when creating dates.

let zoned = Temporal.ZonedDateTime.from('2025-04-03T00:00Z[UTC]');
console.log(zoned.toString());

Temporal is very useful when manipulating and displaying the dates in different time zones.

let utc = Temporal.ZonedDateTime.from('2025-04-03T00:00Z[UTC]'); // Created as UTC
console.log(utc.toString());
//2025-04-03T00:00:00+00:00[UTC]

let clientZoned = zoned.withTimeZone(Temporal.Now.timeZoneId()); // Convert to the client timezone

console.log(clientZoned.toString());
// 2025-04-02T21:00:00-03:00[America/Santiago]

Let's try some more things that are currently difficult or lead to unexpected behavior using the Date object.

Operations like adding days or minutes can lead to inconsistent results. However, Temporal makes these operations easier and consistent.

let date = new Date('2025-03-09');
console.log(date); // 2025-03-09T00:00:00.000Z

// add 100 days
date.setDate(date.getDate + 100));
console.log(date); // 2025-06-17T01:00:00.000Z

const zoned = Temporal.ZonedDateTime.from('2025-03-09[UTC]');
console.log(zoned.toString()); // 2025-03-09T00:00:00+00:00[UTC]
console.log(zoned.add({days:100}).toString()); // 2025-06-17T00:00:00+00:00[UTC]

Another interesting feature of Temporal is the concept of Duration, which is the difference between two time points. We can use these durations, along with dates, for arithmetic operations involving dates and times. Note that Durations are serialized using the ISO 8601 duration format

const duration = Temporal.Duration.from({ hours: 5, minutes: 15 });
console.log(duration.toString());
// PT5H15M

const zoned = Temporal.ZonedDateTime.from('2025-03-09[UTC]');
console.log(zoned.toString()); // 2025-03-09T00:00:00+00:00[UTC]
console.log(zoned.add(duration).toString()); // 2025-03-09T00:05:15+00:00[UTC]

Temporal Objects

We've already seen some of the objects that Temporal exposes. Here's a more comprehensive list.

  • Temporal
  • Temporal.Duration`
  • Temporal.Instant
  • Temporal.Now
  • Temporal.PlainDate
  • Temporal.PlainDateTime
  • Temporal.PlainMonthDay
  • Temporal.PlainTime
  • Temporal.PlainYearMonth
  • Temporal.ZonedDateTime

Try Temporal Today

If you want to test Temporal now, there's a polyfill available. You can install it using:

npm install @js-temporal/polyfill

Note that this doesn't install a global Temporal object as expected in the final release, but it provides most of the Temporal implementation for testing purposes.

Conclusion

Working with dates in JavaScript has always been a bit of a mess. Between weird quirks in the Date object, juggling time zones, and trying to do simple things like “add a day,” it’s way too easy to introduce bugs.

Temporal is finally fixing that. It gives us a clear, consistent, and powerful way to work with dates and times.

If you’ve ever struggled with JavaScript dates (and who hasn’t?), Temporal is definitely worth checking out.

About the author

Ignacio Falk

Ignacio Falk

Senior Software Engineer

I love to learn new things and share what I know. Mentor, Writer, Speaker Member of the local community

Keep reading

View all posts →

Understanding Sourcemaps: From Development to Production

Modern web development involves transforming your source code before deploying it. We minify JavaScript to reduce file sizes, bundle multiple files together, transpile TypeScript to JavaScript, and convert modern syntax into browser-compatible code....

Ignacio Falk5 mins
JavaScript

Next.js + MongoDB Connection Storming

Building a Next.js application connected to MongoDB can feel like a match made in heaven. MongoDB stores all of its data as JSON objects, which don’t require transformation into JavaScript objects like relational SQL data does....

Brandon Mathis3 mins
NextJSJavaScript

The Importance of a Scientific Mindset in Software Engineering: Part 2 (Debugging)

Part 2 of the “scientific mindset” series dives into the structured world of scientific debugging. Rather than relying on guesswork, we’ll explore how to form testable hypotheses to pinpoint and resolve software defects efficiently....

Jan Kaiser13 mins
JavaScript

“Music and code have a lot in common,” freeCodeCamp’s Jessica Wilkins on what the tech community is doing right to onboard new software engineers

Before she was a software developer at freeCodeCamp, Jessica Wilkins was a classically trained clarinetist performing across the country. Her days were filled with rehearsals, concerts, and teaching, and she hadn’t considered a tech career until the world changed in 2020. “When the pandemic hit, most of my gigs were canceled,” she says. “I suddenly had time on my hands and an idea for a site I wanted to build.” That site, a tribute to Black musicians in classical and jazz music, turned into much more than a personal project. It opened the door to a whole new career where her creative instincts and curiosity could thrive just as much as they had in music. Now at freeCodeCamp, Jessica maintains and develops the very JavaScript curriculum that has helped her and millions of developers around the world. We spoke with Jessica about her advice for JavaScript learners, why musicians make great developers, and how inclusive communities are helping more women thrive in tech. Jessica’s Top 3 JavaScript Skill Picks for 2025 If you ask Jessica what it takes to succeed as a JavaScript developer in 2025, she won’t point you straight to the newest library or trend. Instead, she lists three skills that sound simple, but take real time to build: “Learning how to ask questions and research when you get stuck. Learning how to read error messages. And having a strong foundation in the fundamentals” She says those skills don’t come from shortcuts or shiny tools. They come from building. “Start with small projects and keep building,” she says. “Books like You Don’t Know JS help you understand the theory, but experience comes from writing and shipping code. You learn a lot by doing.” And don’t forget the people around you. “Meetups and conferences are amazing,” she adds. “You’ll pick up things faster, get feedback, and make friends who are learning alongside you.” Why So Many Musicians End Up in Tech A musical past like Jessica’s isn’t unheard of in the JavaScript industry. In fact, she’s noticed a surprising number of musicians making the leap into software. “I think it’s because music and code have a lot in common,” she says. “They both require creativity, pattern recognition, problem solving… and you can really get into flow when you’re deep in either one.” That crossover between artistry and logic feels like home to people who’ve lived in both worlds. What the Tech Community Is Getting Right Jessica has seen both the challenges and the wins when it comes to supporting women in tech. “There’s still a lot of toxicity in some corners,” she says. “But the communities that are doing it right—like Women Who Code, Women in Tech, and Virtual Coffee—create safe, supportive spaces to grow and share experiences.” She believes those spaces aren’t just helpful, but they’re essential. “Having a network makes a huge difference, especially early in your career.” What’s Next for Jessica Wilkins? With a catalog of published articles, open source projects under her belt, and a growing audience of devs following her journey, Jessica is just getting started. She’s still writing. Still mentoring. Still building. And still proving that creativity doesn’t stop at the orchestra pit—it just finds a new stage. Follow Jessica Wilkins on X and Linkedin to keep up with her work in tech, her musical roots, and whatever she’s building next. Sticker illustration by Jacob Ashley....

3 mins
JavaScriptSoftware Engineering