JavaScript Temporal Now
The Temporal.Now object provides clear and flexible ways to get the current date and time.
Unlike the JavaScript Date object, Temporal has methods for getting the current time in various formats:
- Temporal.Now.instant()
- Temporal.Now.plainDateISO()
- Temporal.Now.plainTimeISO()
- Temporal.Now.plainDateTimeISO()
- Temporal.Now.zonedDateTimeISO()
Temporal.Now.instant()
The Temporal.Now.instant() method returns a
Temporal.Instant object
representing the current date and time.
An Instant represents an exact moment in time (UTC). It is similar to a timestamp.
Temporal.Now.plainDateISO()
Use the Temporal.Now.plainDateISO() method for calender date only:
It returns a Temporal.PlainDate object with the current date in the ISO calendar.
Temporal.Now.plainTimeISO()
Use the Temporal.Now.plainTimeISO() method for time only:
It returns a Temporal.PlainTime object with the current time in the ISO calendar.
Temporal.Now.plainDateTimeISO()
Use the plainDateTimeISO() method to get the current date and time without a time zone.
It returns a Temporal.plainDateTime object with the
current date and time without a time zone.
This is useful when you only need local date and time.
Example
Get the current system time:
let dateTime = Temporal.Now.plainDateTimeISO();
Try it Yourself »
Temporal.Now.zonedDateTimeISO()
Use the zonedDateTimeISO() method when you need date and time zone information.
It returns a Temporal.ZonedDateTime object that includes your system's time zone.
Compare With Date
With JavaScript Date, you only get one type of date 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.
Temporal.Now Methods
| Method | Description |
|---|---|
| instant() | Returns current time as a Temporal.Instant object |
| plainDateISO() | Returns current date as a Temporal.PlainDate object |
| plainDateTimeISO() | Returns current date and time as a Temporal.PlainDateTime object |
| plainTimeISO() | Returns current time as a Temporal.PlainTime object |
| timeZoneId | Returns system's time zone as a time zone id |
| zonedDateTimeISO() | Returns current date and time as a Temporal.ZonedDateTime object |