JavaScript Temporal Now
Temporal is the modern way to work with dates and times in JavaScript.
Learn how to get the current date and time using JavaScript Temporal.Now.
See examples of Instant, PlainDate, and ZonedDateTime.
The Temporal.Now object provides methods for getting the current date and time.
Unlike Date, Temporal lets you choose exactly what type of value you want.
Get the Current Instant
An Instant represents an exact moment in time (UTC).
It is similar to a timestamp.
This returns the current moment in UTC.
Get the Current Date (ISO)
If you only need today's date (year, month, day), use plainDateISO().
This returns a PlainDate object using the ISO calendar.
Get the Current Date and Time (No Time Zone)
Use plainDateTimeISO() to get the current date and time without a time zone.
This is useful when you need local date and time but not time zone calculations.
Get the Current Date and Time with Time Zone
Use zonedDateTimeISO() when you need time zone information.
This returns a ZonedDateTime that includes your system's time zone.
Compare With Date
With Date, you only get one type of object.
Temporal gives you separate types depending on what you need.
Instant- Exact moment in UTC.PlainDate- Date only.PlainDateTime- Date and time without zone.ZonedDateTime- Date and time with zone.
When to Use Each Method
Use
instant()for timestamps and comparisons.Use
plainDateISO()for birthdays and calendar dates.Use
plainDateTimeISO()for local scheduling.Use
zonedDateTimeISO()for international or time zone-aware applications.
Summary
Temporal.Now provides clear and flexible ways to get the current date and time.
You can choose the exact type you need instead of using one general-purpose object.