

How to Convert UTC Date Time to Local Date Time in JavaScript
source link: https://www.laravelcode.com/post/how-to-convert-utc-date-time-to-local-date-time-in-javascript
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to Convert UTC Date Time to Local Date Time in JavaScript
Use the toString()
Method
You can simply use the toString()
method to convert UTC or GMT date time to local date time in JavaScript. Greenwich Mean Time (GMT) is a time zone and Coordinated Universal Time (UTC) is a time standard. Although GMT and UTC share the same current time in practice.
Let's try out the following example to understand how this method actually works:
<script>
// Create date object from datetime string
var date = new Date('Tue, 21 Apr 2020 09:20:30 GMT');
// Coverting to local datetime
console.log(date.toString());
// Coverting local datetime back to UTC
console.log(date.toUTCString()); // Tue, 21 Apr 2020 09:20:30 GMT
</script>
Author : Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Recommend
-
23
SMA Runbooks And UTC Time I don’t know about you but I hate dealing with systems that use UTC time. I have SMA runbooks that work with Exchange 2013, Exchange Online Protection and other services that annoyingly return r...
-
18
Home » How To Guides » PHP » How to Convert Local DateTime to UTC in PHP...
-
6
Convert Variables and Strings to Date-Time Format advertisements I currently have the following variables and f...
-
7
Determine whether the time is UTC or EST advertisements I have the var date = new Date() by this d...
-
7
While working with dates in JavaScript, we often need to convert milliseconds to a date value as we need to process them. This article will write functions to convert timestamps to human dates. Convert Milliseconds to a Date Value usi...
-
13
Javascript Convert Date and Time Example 158 views 5 months ago Javascript In this article, we will share with y...
-
3
UTC vs. UT1 time (and other nuances) UTC vs. UT1 time (and other nuances) The below notes capture my understanding of the different nuances in the definition of UT1, TAI and UTC...
-
8
Javascript program to convert Date to NumberSkip to content
-
5
February 2, 2023 /
-
8
The Best Way to Convert JavaScript Date to ISO String We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. By clicking "Accept All", you consent...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK