Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The toLocaleString()
method of Temporal.ZonedDateTime
instances returns a string with a language-sensitive representation of this date-time. In implementations with Intl.DateTimeFormat
API support, this method delegates to Intl.DateTimeFormat
and passes this date-time converted to an Temporal.Instant
(because Intl.DateTimeFormat
cannot directly format a Temporal.ZonedDateTime
).
Every time toLocaleString
is called, it has to perform a search in a big database of localization strings, which is potentially inefficient. When the method is called many times with the same arguments, it is better to create a Intl.DateTimeFormat
object and use its format()
method, because a DateTimeFormat
object remembers the arguments passed to it and may decide to cache a slice of the database, so future format
calls can search for localization strings within a more constrained context. However, currently Intl.DateTimeFormat
does not support formatting Temporal.ZonedDateTime
objects, so you must convert them to Temporal.Instant
objects first before passing them to format()
.