Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
How to check if date is less than 1 hour ago using JavaScript ?
Next article icon

How to Convert Date to Another Timezone in JavaScript?

Last Updated : 06 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Converting a date to another timezone in JavaScript means adjusting the local date and time to match the time in a different timezone. This ensures that the displayed time aligns with the selected timezone, often using built-in methods or external libraries.

1. Using Intl.DateTimeFormat() and format() Methods

Intl.DateTimeFormat() in JavaScript allows formatting dates according to a specific locale and timezone. By using the format() method, you can convert a date into a human-readable string, adapting it to the desired timezone and regional formatting conventions.

Syntax

intlDateObj = new Intl.DateTimeFormat('en-US', {
timeZone: "America/New_York"
});
usaTime = intlDateObj.format(date);
JavaScript
let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));  console.log('Given IST datetime: ', date);  let intlDateObj = new Intl.DateTimeFormat('en-US', {     timeZone: "America/New_York" });  let usaTime = intlDateObj.format(date); console.log('USA date: ', usaTime); 

Output
Given IST datetime:  2012-12-20T03:00:00.000Z USA date:  12/19/2012 

2. Using toLocaleString() Method

The toLocaleString() method is used to return a string that formats the date according to the locale and options specified. It will convert the date on which the method is used from one timezone to another. 

Syntax

usaTime = date.toLocaleString("en-US", {timeZone: "America/New_York"});
JavaScript
let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); console.log('Given IST datetime: ', date);  let usaTime = date.toLocaleString("en-US", {     timeZone: "America/New_York" });  console.log('USA datetime: ', usaTime); 

Output
Given IST datetime:  2012-12-20T03:00:00.000Z USA datetime:  12/19/2012, 10:00:00 PM 

Next Article
How to check if date is less than 1 hour ago using JavaScript ?
author
sayantanm19
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • javascript-date
  • JavaScript-Questions

Similar Reads

  • How to get tomorrow's date in a string format in JavaScript ?
    In this article, we will see how to print tomorrow's date in string representation using JavaScript. To achieve this, we use the Date object and create an instance of it. After that by using the setDate() method, we increase one date to the present date. Now by using the getDate() method you will ge
    2 min read
  • How to check for two timestamp for the same day?
    Given two timestamp then we have to find out whether these time are of same date or not. Here we can use the JavaScript Date Object. Examples: Input: TimeStamp1 = 20-04-2020 , 16:04:55 and TimeStamp2 = 20-04-2020 , 10:22:42 Output: These dates are of same dateInput: TimeStamp1 = 20-04-2020 , 16:04:5
    3 min read
  • How to get seconds since epoch in JavaScript?
    Given a date, we have to find the number of seconds since the epoch (i.e. 1 January 1970, 00:00:00 UTC ). The getTime() method in the JavaScript returns the number of milliseconds since January 1, 1970, or epoch. If we divide these milliseconds by 1000 and then integer part will give us the number o
    1 min read
  • How to check if one date is between two dates in JavaScript ?
    The task is to determine if the given date is in between the given 2 dates or not? Here are a few of the most used techniques discussed with the help of JavaScript. In the first approach, we will use .split() method and the new Date() constructor. And in the second approach we will use the .getTime(
    3 min read
  • How to check if the given date is weekend ?
    To check if a given date falls on a weekend in JavaScript, you can use the getDay() method on a Date object. This method returns a number representing the day of the week, where 0 is Sunday and 6 is Saturday. There are two methods to solve this problem which are discussed below: Table of Content Usi
    2 min read
  • How to Convert Date to Another Timezone in JavaScript?
    Converting a date to another timezone in JavaScript means adjusting the local date and time to match the time in a different timezone. This ensures that the displayed time aligns with the selected timezone, often using built-in methods or external libraries. 1. Using Intl.DateTimeFormat() and format
    2 min read
  • How to check if date is less than 1 hour ago using JavaScript ?
    Given a date and the task is to check whether the given date is less than 1 hour ago or not with the help of JavaScript. Approach 1: Count the milliseconds of the difference between the current and prev_date.If those are greater than milliseconds in 1 hour, then it returns false otherwise returns tr
    2 min read
  • How to check a date is valid or not using JavaScript?
    To check if a date is valid or not in JavaScript, we have to know all the valid formats of the date. For ex - "YYYY/DD/MM", "DD/MM/YYYY", and "YYYY-MM-DD", etc. We have a given date format and we need to check whether the given format is valid or not according to the official and acceptable date for
    3 min read
  • How to get the day and month of a year using JavaScript ?
    Given a date and the task is to get the day and month of a year using JavaScript. Approach: First get the current date by using new Date().Use getDay() method to get the current day in number format, Map it to the day name.Use getMonth() to get the current month in number format, Map it to the month
    2 min read
  • How to calculate the date three months prior using JavaScript ?
    To calculate the date three months prior using JavaScript, we could use the getMonth() and setMonth() methods. In this article, we are going to learn how to calculate the date three months prior using JavaScript. ApproachFirst, select the date object.Then use the getMonth() method to get the months.
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences