Take my timezone as an example (AEST):

function parseDate(str_date) {
  return new Date(Date.parse(str_date));
}


var str_date = "2015-05-01T22:00:00+10:00"; //AEST time
var locale_date = parseDate(str_date);

locale_date: Fri May 01 2015 22:00:00 GMT+1000 (AEST)

var str_date = "2015-05-01T22:00:00+00:00" //UTC time
var locale_date = parseDate(str_date);

locale_date: Sat May 02 2015 08:00:00 GMT+1000 (AEST)

Answer from Leo on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toLocaleTimeString
Date.prototype.toLocaleTimeString() - JavaScript | MDN
When the method is called many times with the same arguments, it is better to create an 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. // Depending on timezone, your results will vary const event = new Date("August 19, 1975 23:15:30 GMT+00:00"); console.log(event.toLocaleTimeString("en-US")); // Expected output: "1:15:30 AM" console.log(event.toLocaleTimeString("it-IT")); // Expected output: "01:15:30" console.log(event.toLocaleTimeString("ar-EG")); // Expected output: "١٢:١٥:٣٠ ص"
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toTimeString
Date.prototype.toTimeString() - JavaScript | MDN
const d = new Date(0); console.log(d.toString()); // "Thu Jan 01 1970 00:00:00 GMT+0000 (Coordinated Universal Time)" console.log(d.toTimeString()); // "00:00:00 GMT+0000 (Coordinated Universal Time)" ... This page was last modified on Jul 10, 2025 by MDN contributors.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toISOString
Date.prototype.toISOString() - JavaScript | MDN
const event = new Date("05 October 2011 14:48 UTC"); console.log(event.toString()); // Expected output: "Wed Oct 05 2011 16:48:00 GMT+0200 (CEST)" // Note: your timezone may vary console.log(event.toISOString()); // Expected output: "2011-10-05T14:48:00.000Z" ... A string representing the given date in the date time string format according to universal time.
🌐
Go Make Things
gomakethings.com › getting-a-date-in-the-current-users-timezone-with-javascript
Getting a date in the current user's timezone with JavaScript | Go Make Things
An API they’re using returns the date as a string in a fixed timezone (in their case, Denver, Colorado, USA), like this… let dateFromAPI = '2025-01-31T11:50:15'; And they wanted to display it as a formatted string in the current user’s local time. JavaScript makes this a lot harder than ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toString
Date.prototype.toString() - JavaScript | MDN
Date.prototype.toString() returns a string representation of the Date as interpreted in the local timezone, containing both the date and the time — it joins the string representation specified in toDateString() and toTimeString() together, adding a space in between.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › parse
Date.parse() - JavaScript | MDN
The following call, which does not specify a time zone will be set to 2019-01-01 at 00:00:00 in the local timezone of the system, because it has both date and time. ... Apart from the standard date time string format, the toString() and toUTCString() formats are supported:
Top answer
1 of 16
969

Background

JavaScript's Date object tracks time in UTC internally, but typically accepts input and produces output in the local time of the computer it's running on. It has very few facilities for working with time in other time zones.

The internal representation of a Date object is a single number - namely timestamp - representing the number of milliseconds that have elapsed since 1970-01-01 00:00:00 UTC, without regard to leap seconds.

There is no time zone or string format stored in the Date object itself.

When various functions of the Date object are used, the computer's local time zone is applied to the internal representation. If the function produces a string, then the computer's locale information may be taken into consideration to determine how to produce that string. The details vary per function, and some are implementation-specific.

The only operations the Date object can do with non-local time zones are:

  • It can parse a string containing a numeric UTC offset from any time zone. It uses this to adjust the value being parsed, and stores the UTC equivalent. The original local time and offset are not retained in the resulting Date object. For example:

      var d = new Date("2020-04-13T00:00:00.000+08:00");
      d.toISOString()  //=> "2020-04-12T16:00:00.000Z"
      d.valueOf()      //=> 1586707200000  (this is what is actually stored in the object)
    
  • In environments that have implemented the ECMASCript Internationalization API (aka "Intl"), a Date object can produce a locale-specific string adjusted to a given time zone identifier. This is accomplished via the timeZone option to toLocaleString and its variations. Most implementations will support IANA time zone identifiers, such as 'America/New_York'. For example:

      var d = new Date("2020-04-13T00:00:00.000+08:00");
      d.toLocaleString('en-US', { timeZone: 'America/New_York' })
      //=> "4/12/2020, 12:00:00 PM"
      // (midnight in China on April 13th is noon in New York on April 12th)
    

    Most modern environments support the full set of IANA time zone identifiers (see the compatibility table here). However, keep in mind that the only identifier required to be supported by Intl is 'UTC', thus you should check carefully if you need to support older browsers or atypical environments (for example, lightweight IoT devices).

Libraries

There are several libraries that can be used to work with time zones. Though they still cannot make the Date object behave any differently, they typically implement the standard IANA timezone database and provide functions for using it in JavaScript. Modern libraries use the time zone data supplied by the Intl API, but older libraries typically have overhead, especially if you are running in a web browser, as the database can get a bit large. Some of these libraries also allow you to selectively reduce the data set, either by which time zones are supported and/or by the range of dates you can work with.

Here are the libraries to consider:

Intl-based Libraries

New development should choose from one of these implementations, which rely on the Intl API for their time zone data:

  • Luxon (successor of Moment.js)
  • date-fns-tz (extension for date-fns)
  • Day.js (when using its Timezone plugin)

Non-Intl Libraries

These libraries are maintained, but carry the burden of packaging their own time zone data, which can be quite large.

  • js-joda/timezone (extension for js-joda)
  • moment-timezone* (extension for Moment.js)
  • date-fns-timezone (extension for older 1.x of date-fns)
  • BigEasy/TimeZone
  • tz.js

* While Moment and Moment-Timezone were previously recommended, the Moment team now prefers users chose Luxon for new development.

Discontinued Libraries

These libraries have been officially discontinued and should no longer be used.

  • WallTime-js
  • TimeZoneJS

Future Proposals

The TC39 Temporal Proposal aims to provide a new set of standard objects for working with dates and times in the JavaScript language itself. This will include support for a time zone aware object.

Common Errors

There are several approaches that are often tried, which are in error and should usually be avoided.

Re-Parsing

new Date(new Date().toLocaleString('en', {timeZone: 'America/New_York'}))

The above approach correctly uses the Intl API to create a string in a specific time zone, but then it incorrectly passes that string back into the Date constructor. In this case, parsing will be implementation-specific, and may fail entirely. If successful, it is likely that the resulting Date object now represents the wrong instant in time, as the computer's local time zone would be applied during parsing.

Epoch Shifting

var d = new Date();
d.setTime(d.getTime() + someOffset * 60000);

The above approach attempts to manipulate the Date object's time zone by shifting the Unix timestamp by some other time zone offset. However, since the Date object only tracks time in UTC, it actually just makes the Date object represent a different point in time.

The same approach is sometimes used directly on the constructor, and is also invalid.

Epoch Shifting is sometimes used internally in date libraries as a shortcut to avoid writing calendar arithmetic. When doing so, any access to non-UTC properties must be avoided. For example, once shifted, a call to getUTCHours would be acceptable, but a call to getHours would be invalid because it uses the local time zone.

It is called "epoch shifting", because when used correctly, the Unix Epoch (1970-01-01T00:00:00.000Z) is now no longer correlated to a timestamp of 0 but has shifted to a different timestamp by the amount of the offset.

If you're not authoring a date library, you should not be epoch shifting.

For more details about epoch shifting, watch this video clip from Greg Miller at CppCon 2015. The video is about time_t in C++, but the explanation and problems are identical. (For JavaScript folks, every time you hear Greg mention time_t, just think "Date object".)

Trying to make a "UTC Date"

var d = new Date();
var utcDate = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()));

In this example, both d and utcDate are identical. The work to construct utcDate was redundant, because d is already in terms of UTC. Examining the output of toISOString, getTime, or valueOf functions will show identical values for both variables.

A similar approach seen is:

var d = new Date();
var utcDate = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());

This is approach passes UTC values into the Date constructor where local time values are expected. The resulting Date object now represents a completely different point in time. It is essentially the same result as epoch shifting described earlier, and thus should be avoided.

The correct way to get a UTC-based Date object is simply new Date(). If you need a string representation that is in UTC, then use new Date().toISOString().

2 of 16
250

As Matt Johnson said

If you can limit your usage to modern web browsers, you can now do the following without any special libraries:

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

This isn't a comprehensive solution, but it works for many scenarios that require only output conversion (from UTC or local time to a specific time zone, but not the other direction).

So although the browser can not read IANA timezones when creating a date, or has any methods to change the timezones on an existing Date object, there seems to be a hack around it.

Consider the following function

function changeTimezone(date, ianatz) {

  // suppose the date is 12:00 UTC
  var invdate = new Date(date.toLocaleString('en-US', {
    timeZone: ianatz
  }));

  // then invdate will be 07:00 in Toronto
  // and the diff is 5 hours
  var diff = date.getTime() - invdate.getTime();

  // so 12:00 in Toronto is 17:00 UTC
  return new Date(date.getTime() - diff); // needs to substract

}

However, closely looking at the return value, this can be simplified to:

function changeTimezone(date, ianatz) {
  return new Date(date.toLocaleString('en-US', {
    timeZone: ianatz
  }));
}

// E.g.
var here = new Date();
var there = changeTimezone(here, "America/Toronto");

console.log(`Here: ${here.toString()}\nToronto: ${there.toString()}`);

Find elsewhere
🌐
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.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › date › date to iso format with timezone
Format a date to ISO string with timezone using JavaScript - 30 seconds of code
January 7, 2024 - JavaScript's built-in Date.prototype.toISOString() method converts a date to ISO string in UTC time. const toISOString = date => date.toISOString(); toISOString( new Date('2024-01-06T19:20:34+02:00') ); // '2024-01-06T17:20:34.000Z' In order ...
🌐
Plain English
plainenglish.io › blog › how-to-initialize-a-javascript-date-to-a-particular-time-zone-a03969601c58
How to Initialize a JavaScript Date to a Particular Time Zone?
The JavaScrip date object has the toLocaleString method to convert a date to a date string in the given time zone. ... const d = new Date("2020-04-13T00:00:00.000+08:00"); const dateStr = d.toLocaleString('en-US', { timeZone: 'America/New_York' ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-date-to-another-timezone-in-javascript
How to Convert Date to Another Timezone in JavaScript? - GeeksforGeeks
July 12, 2025 - This ensures that the displayed time aligns with the selected timezone, often using built-in methods or external libraries. Intl.DateTimeFormat() in JavaScript allows formatting dates according to a specific locale and timezone.
🌐
Twilio
twilio.com › en-us › blog › converting-formatting-dates-timezones-javascript
Converting and Formatting Dates and Time Zones with JavaScript | Twilio
January 26, 2024 - Date string: Wed Jun 22 2022 17:15:19 GMT-0700 (Pacific Daylight Time) Intl.DateTimeFormat string: Thursday 09:15 · Without modifying your environment variables or adding a dependency, you just converted and formatted your local time to match that of our friends in Japan! To verify the safety of the time conversion, let’s try to trick your code again by picking a different time zone from your console:
🌐
Ursahealth
ursahealth.com › new-insights › dates-and-timezones-in-javascript
Working with dates and timezones in JavaScript: a survival guide
May 4, 2021 - Likewise, toISOString() always returns the date in UTC time, which you can tell because the string ends in the letter Z, indicating UTC time for historical reasons related to the British Empire (and are beyond the scope of this article). Either way, the JavaScript date always represents a moment in time in the universe, such that it can be easily – and most of the time automatically – localized to the user’s environment.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
T is a literal character, which ... of the string. The T is required when specifying the time part. HH is the hour, with two digits (00 to 23). As a special case, 24:00:00 is allowed, and is interpreted as midnight at the beginning of the next day. Defaults to 00. mm is the minute, with two digits (00 to 59). Defaults to 00. ss is the second, with two digits (00 to 59). Defaults to 00. sss is the millisecond, with three digits (000 to 999). Defaults to 000. Z is the timezone offset, which ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toDateString
Date.prototype.toDateString() - JavaScript | MDN
If you want to make the date interpreted as UTC instead of local timezone, use toUTCString(). If you want to format the date in a more user-friendly format (e.g., localization), use toLocaleDateString(). ... const d = new Date(0); console.log(d.toString()); // "Thu Jan 01 1970 00:00:00 GMT+0000 ...
🌐
Netlify
netlify.com › blog › how-to-get-timezone-in-javascript-with-edge-functions
How to get the user‘s timezone in JavaScript with Edge Functions
To adjust a date by timezone in JavaScript, you can use the Date object and its toLocaleString() method.
🌐
UsefulAngle
usefulangle.com › post › 30 › javascript-get-date-time-with-offset-hours-minutes
How to get DateTime with Timezone Offset (8601 format) in Javascript
var timezone_offset_min = new Date().getTimezoneOffset(), offset_hrs = parseInt(Math.abs(timezone_offset_min/60)), offset_min = Math.abs(timezone_offset_min`), timezone_standard; if(offset_hrs < 10) offset_hrs = '0' + offset_hrs; if(offset_min < 10) offset_min = '0' + offset_min; // Add an opposite sign to the offset // If offset is 0, it means timezone is UTC if(timezone_offset_min < 0) timezone_standard = '+' + offset_hrs + ':' + offset_min; else if(timezone_offset_min > 0) timezone_standard = '-' + offset_hrs + ':' + offset_min; else if(timezone_offset_min == 0) timezone_standard = 'Z'; // Timezone difference in hours and minutes // String such as +5:30 or -6:00 or Z console.log(timezone_standard); You can get current datetime using the Date object.