update

There is pretty extensive write-up about the API here


Is this part of a new standard? Perhaps buried somewhere in ECMAScript 6? Or is it just something custom to Chrome?

Yes, these are part of the ECMAScript Internationalization API. It is implemented separate from ECMAScript, but the requirement of implementing ECMAScript Internationalization API is to first have correct implementation of ECMAScript 5.1

Why just Google Chrome? Is it supported anywhere else? Are there plans to supported it anywhere else?

For the recent years, Google Chrome has mostly been first to implement new features. Mozilla is more conservative, still for example discussing whether to implement the download attribute of a elements. It is now available in IE11 Beta and Opera too. It will be available in Firefox 25.

I checked node.js, which uses Chrome's JavaScript runtime, but it doesn't work there. Why not?

node.js just uses the same engine, which is a separate project from the Google Chrome browser. The engine just implements Ecmascript 5.1. This is an extension node.js would have to implement separately right now. It will become available in V8 in Q3 so probably a bit after that you can use it in node.js.

This is focused on output, but how would I use it for input? Is there a way to pass the time zone in the constructor to the Date object? I tried the following:

There is nothing about inputting dates in the specification. I personally cannot see how this would be useful, you are doing it wrong if you are not transmitting UTC timestamps because something like "2013-01-01 12:34:56 America/New_York" is ambiguous during transitions from DST to standard time.

The issue described in this post, created by a flaw in the ECMAScript 5 spec, still affects the output, even when the correct data is in the TZDB.

This is input issue, not output. Again, constructing a date with local timezone that you cannot influence or detect is doing it wrong. Use the timestamp constructor overload or Date.UTC.

Can I expect that as IANA releases updates to the TZDB that Google will push Chrome updates that contain the changes?

Nothing in the spec but I think it will be reasonable to expect that the rules are not too much behind.

Answer from Esailija on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toLocaleDateString
Date.prototype.toLocaleDateString() - JavaScript | MDN
The toLocaleDateString() method of Date instances returns a string with a language-sensitive representation of the date portion of this date in the local timezone.
🌐
W3Schools
w3schools.com › jsref › jsref_tolocalestring.asp
W3Schools.com
new Date() constructor getDate() getDay() getFullYear() getHours() getMilliseconds() getMinutes() getMonth() getSeconds() getTime() getTimezoneOffset() getUTCDate() getUTCDay() getUTCFullYear() getUTCHours() getUTCMilliseconds() getUTCMinutes() getUTCMonth() getUTCSeconds() now() parse() prototype setDate() setFullYear() setHours() setMilliseconds() setMinutes() setMonth() setSeconds() setTime() setUTCDate() setUTCFullYear() setUTCHours() setUTCMilliseconds() setUTCMinutes() setUTCMonth() setUTCSeconds() toDateString() toISOString() toJSON() toLocaleDateString() toLocaleTimeString() toLocaleString() toString() toTimeString() toUTCString() UTC() valueOf() JS Function
Top answer
1 of 2
27

update

There is pretty extensive write-up about the API here


Is this part of a new standard? Perhaps buried somewhere in ECMAScript 6? Or is it just something custom to Chrome?

Yes, these are part of the ECMAScript Internationalization API. It is implemented separate from ECMAScript, but the requirement of implementing ECMAScript Internationalization API is to first have correct implementation of ECMAScript 5.1

Why just Google Chrome? Is it supported anywhere else? Are there plans to supported it anywhere else?

For the recent years, Google Chrome has mostly been first to implement new features. Mozilla is more conservative, still for example discussing whether to implement the download attribute of a elements. It is now available in IE11 Beta and Opera too. It will be available in Firefox 25.

I checked node.js, which uses Chrome's JavaScript runtime, but it doesn't work there. Why not?

node.js just uses the same engine, which is a separate project from the Google Chrome browser. The engine just implements Ecmascript 5.1. This is an extension node.js would have to implement separately right now. It will become available in V8 in Q3 so probably a bit after that you can use it in node.js.

This is focused on output, but how would I use it for input? Is there a way to pass the time zone in the constructor to the Date object? I tried the following:

There is nothing about inputting dates in the specification. I personally cannot see how this would be useful, you are doing it wrong if you are not transmitting UTC timestamps because something like "2013-01-01 12:34:56 America/New_York" is ambiguous during transitions from DST to standard time.

The issue described in this post, created by a flaw in the ECMAScript 5 spec, still affects the output, even when the correct data is in the TZDB.

This is input issue, not output. Again, constructing a date with local timezone that you cannot influence or detect is doing it wrong. Use the timestamp constructor overload or Date.UTC.

Can I expect that as IANA releases updates to the TZDB that Google will push Chrome updates that contain the changes?

Nothing in the spec but I think it will be reasonable to expect that the rules are not too much behind.

2 of 2
6

Is this part of a new standard? Perhaps buried somewhere in ECMAScript 6? Or is it just something custom to Chrome?

Indeed it is part of the new ECMA-402 standard. The standard is very difficult to read, but there is this friendly introduction.

Why just Google Chrome? Is it supported anywhere else? Are there plans to supported it anywhere else?

MDN has a list of supporting browsers. According to Bug 853301 it will be available in Firefox 25.

I checked node.js, which uses Chrome's JavaScript runtime, but it doesn't work there. Why not?

Possible reasons are many; it is not up to the current code base, or it would make the node.js bigger and slower (the previous bug tracker entry from Mozilla indicates that the timezone data increased the download size of Firefox by 10 %, and caused the I/O to increase substantially during browser start up.

Is the time zone data accessible in any other way than the functions I listed? If only
available when formatting strings, then doing any calculations based on the results may be difficult.

Seems that it is not available. Furthermore, the Intl API primer talks that only UTC and local time zone are absolutely required to be supported.

This is focused on output, but how would I use it for input? Is there a way to pass the time zone in the constructor to the Date object? I tried the following:

The Intl API only speaks about date/time formatting, string collations and number formatting. The datetime formatting not only supports the Gregorian calendar but also many kinds of other calendars, lunar, lunisolar and so forth.

The issue described in this post, created by a flaw in the ECMAScript 5 spec, still affects the output, even when the correct data is in the TZDB. How is it that both old and new implementations are coexisting? One would think it would be all the old way, or all the new way. For example, with my computer's time zone set to US Eastern Time:

new Date(2004,10,7,0,0).toLocaleString("en-US",{timeZone:"America/New_York"})

returns "11/6/2004 11:00:00 PM". It should return midnight, since I started at midnight and > my local time zone matches the output time zone. But it places the provided input date at the > wrong UTC point due to the ES5 issue.

The reason for that is that ES5 mandates that the input to new Date be calculated using the current DST and offset, that is it is America/New York but with EDT timezone, even though Nov 6 is not in EDT. Obviously as this is so specified, then it cannot be changed. However, as Chrome is using the TZDB to do the conversion from the bare UTC point-in-time value to the America/New York tz, it then does consider the time as being in EST.

Can I expect that as IANA releases updates to the TZDB that Google will push Chrome updates that contain the changes?

I'd believe so

🌐
Medium
simonsc.medium.com › working-with-time-zones-in-javascript-1b57e716d273
Working with Time Zones in JavaScript | by Simon SC | Medium
March 15, 2021 - let date = new Date();date.toLocaleString("en-us", {timeZone: "utc"}); // returns "3/15/2021, 7:22:36 PM"date.toLocaleDateString("en-gb", {timeZone: "utc"}) // returns "15/03/2021"date.toLocaleTimeString([], {timeZone: "utc"}) // returns "19:22:36"date.toISOString(); // returns "2021-03-15T19:22:36.245Z"
🌐
Peterbe.com
peterbe.com › plog › be-careful-with-date.tolocaledatestring
Be careful with Date.toLocaleDateString() in JavaScript - Peterbe.com
May 8, 2023 - Welcome to Node.js v16.20.0. Type ".help" for more information. > new Date('2014-11-27T02:50:49Z').toLocaleDateString("en-us", {day: "numeric", timeZone: "UTC"}) '27'
🌐
GitHub
github.com › sebastienros › jint › issues › 557
toLocaleDateString format and timezone · Issue #557 · sebastienros/jint
August 10, 2018 - Format a date to a specific format and timezone. Code: var d = new Date().toLocaleDateString('zh-Hans-CN', {timeZone: 'America/Denver', hour12: false }); Results: JS: d= 2018/11/26 Jint: d= Monday, November 26, 2018
Published   Nov 26, 2018
🌐
Phrase
phrase.com › home › resources › blog › a guide to date and time localization
A Guide to Date and Time Localization | Phrase
July 31, 2025 - // English-America date.toLocaleTimeString("en-US", { timeZone: "UTC" }); // => "2:00:00 PM" // Arabic-Egypt date.toLocaleTimeString("ar-EG", { timeZone: "UTC" }); // => "٢:٠٠:٠٠ م" // Hindi-India date.toLocaleTimeString("hi-IN", { timeZone: "UTC" }); // => "2:00:00 pm" // Russian-Russia date.toLocaleTimeString("ru-RU", { timeZone: "UTC" }); // => "14:00:00" // Chinese-China date.toLocaleTimeString("zh-CN", { timeZone: "UTC" }); // => "14:00:00" // Japanese-Japan date.toLocaleTimeString("jp-JP", { timeZone: "UTC" }); // => "2:00:00 p.m."Code language: JavaScript (javascript) 🗒️ Just like Date.toLocaleDateString(), Date.toLocaleTimeString() uses Intl.DateTimeFormat under the hood when it’s available.
Find elsewhere
🌐
Codecademy
codecademy.com › docs › javascript › dates › .tolocaledatestring()
JavaScript | Dates | .toLocaleDateString() | Codecademy
June 2, 2023 - In the example below, .toLocaleDateString() is being used in the en-US locale (more specifically, in the America/Los_Angeles timezone).
🌐
Medium
medium.com › geekculture › level-up-your-date-and-time-formatting-skills-in-javascript-866d8b656092
Level Up Your Date and Time Formatting Skills in JavaScript | by Danielle Dias | Geek Culture | Medium
May 26, 2023 - This parameter allows us to control aspects such as hour12, hour, minute, and second, similar to the options available in toLocaleDateString(). const date = new Date(); const timeOptions = { hour12: true, hour: 'numeric', minute: '2-digit', second: '2-digit', }; console.log(date.toLocaleTimeString('en-US', timeOptions)); // Output: 1:37:15 PM console.log(date.toLocaleTimeString('en-US', { timeZone: 'America/Los_Angeles' })); // Output: 10:37:15 AM
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toLocaleString
Date.prototype.toLocaleString() - JavaScript | MDN
// An application may want to use UTC and make that visible options.timeZone = "UTC"; options.timeZoneName = "short"; console.log(date.toLocaleString("en-US", options)); // Example output: "Thursday, December 20, 2012 at UTC" // Sometimes even the US needs 24-hour time console.log(date.toLocaleString("en-US", { hour12: false })); // Example output: "12/19/2012, 19:00:00" // The exact date and time may shift depending on your local time zone.
🌐
Simon Willison
til.simonwillison.net › javascript › javascript-date-objects
JavaScript date objects | Simon Willison’s TILs
// This outputs in my timezone, PST: (new Date("2021-01-22T15:03:00Z")).toLocaleTimeString("en-US") "7:03:00 AM" // This keeps the output in UTC: (new Date("2021-01-22T15:03:00Z")).toLocaleTimeString( "en-US", {timeZone: "UTC"} ) "3:03:00 PM" MDN documentation: toLocaleDateString() toLocaleTimeString() Lots of useful comments on this in replies on Twitter, including recommendations for these libraries: Intl.DateTimeFormat() for even more advanced formatting options in the browser standards ·
🌐
JavaScript in Plain English
javascript.plainenglish.io › javascript-date-object-locale-methods-to-format-the-date-string-5e3be8343db5
JavaScript Date Object: LOCALE Methods to FORMAT the Date String | by Jakub Korch | JavaScript in Plain English
July 20, 2021 - 7. 2021console.log(new Date().toLocaleDateString('en-US')); // 7/17/2021console.log(new Date().toLocaleDateString('en-GB')); // 17/07/2021console.log(new Date().toLocaleDateString(undefined, optionsDate)); // sobota 17.
Top answer
1 of 16
225

Seems the most foolproof way to start with a UTC date is to create a new Date object and use the setUTC… methods to set it to the date/time you want.

Then the various toLocale…String methods will provide localized output.

Example:

// This would come from the server.
// Also, this whole block could probably be made into an mktime function.
// All very bare here for quick grasping.
d = new Date();
d.setUTCFullYear(2004);
d.setUTCMonth(1);
d.setUTCDate(29);
d.setUTCHours(2);
d.setUTCMinutes(45);
d.setUTCSeconds(26);

console.log(d);                        // -> Sat Feb 28 2004 23:45:26 GMT-0300 (BRT)
console.log(d.toLocaleString());       // -> Sat Feb 28 23:45:26 2004
console.log(d.toLocaleDateString());   // -> 02/28/2004
console.log(d.toLocaleTimeString());   // -> 23:45:26

Some references:

  • toLocaleString
  • toLocaleDateString
  • toLocaleTimeString
  • getTimezoneOffset
2 of 16
66

You can do it with moment.js (deprecated in 2021)

It's best to parse your date string from UTC as follows (create an ISO-8601 compatible string on the server to get consistent results across all browsers):

var m = moment("2013-02-08T09:30:26Z");

Now just use m in your application, moment.js defaults to the local timezone for display operations. There are many ways to format the date and time values or extract portions of it.

You can even format a moment object in the users locale like this:

m.format('LLL') // Returns "February 8 2013 8:30 AM" on en-us

To transform a moment.js object into a different timezone (i.e. neither the local one nor UTC), you'll need the moment.js timezone extension. That page has also some examples, it's pretty simple to use.

Note: Moment JS recommends more modern alternatives, so it is probably not a good choice for new projects.

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toLocaleTimeString
Date.prototype.toLocaleTimeString() - JavaScript | MDN
October 30, 2025 - const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); // An application may want to use UTC and make that visible const options = { timeZone: "UTC", timeZoneName: "short" }; console.log(date.toLocaleTimeString("en-US", options)); // "3:00:00 AM GMT" // Sometimes even the US needs 24-hour time console.log(date.toLocaleTimeString("en-US", { hour12: false })); // "19:00:00" // Show only hours and minutes, use options with the default locale - use an empty array console.log( date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), ); // "20:01"
🌐
Linangdata
linangdata.com › snippets-of-javascript › format-date
How to format a JavaScript date?
July 13, 2022 - The toLocaleString() method returns a string with a language-sensitive representation of this date. It is different to toLocaleDateString in that it returns the time as well. const today = new Date(); today.toLocaleString("en-US", { timeZone: ...
🌐
MSR
rajamsr.com › home › how to use tolocaledatestring() to create stunning date formats
How to Use toLocaleDateString() to Create Stunning Date Formats | MSR - Web Dev Simplified
March 4, 2024 - To specify the time zone for Shanghai, China, we set the timeZone property to “Asia/Shanghai”. Then we call the toLocaleDateString() method on the date object and pass in the options object as the second parameter.
🌐
SHDate homepage
md-akhi.github.io › SHDateTime-js › en › toLocaleDateString
SHDate homepage
The toLocaleDateString() method returns a string with a language sensitive representation of the date portion of the specified date in the user agent’s timezone.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-format-a-date-with-javascript-date-formatting-in-js
How to Format a Date with JavaScript – Date Formatting in JS
November 7, 2024 - const date = new Date(); const formattedDate = date.toLocaleString('en-US', { timeZoneName: 'short' }); console.log(formattedDate);
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-date-tolocaledatestring-method
JavaScript Date toLocaleDateString() Method | GeeksforGeeks
July 12, 2024 - let dateObj = new Date(); let options = { weekday: "long", year: "numeric", month: "short", day: "numeric" }; console.log(dateObj.toLocaleDateString("en-US")); console.log(dateObj.toLocaleDateString("en-US", options));