Javascript Convert Utc Date Time To Local Date

[Solved] Javascript Convert Utc Date Time To Local Date | Whatever - Code Explorer | yomemimo.com
Question : convert local time to utc javascript

Answered by : you

// Get current local date and time
const localDate = new Date();
// Convert local date and time to UTC
const utcDate = new Date(localDate.getTime() + localDate.getTimezoneOffset() * 60000);
// Format the UTC date and time as a string
const utcDateString = utcDate.toISOString();
console.log(utcDateString);

Source : | Last Update : Tue, 19 Sep 23

Question : javascript convert utc to local time

Answered by : vastemonde

var date = new Date('6/29/2011 4:52:48 PM UTC');
date.toString() // "Wed Jun 29 2011 09:52:48 GMT-0700 (PDT)"

Source : https://stackoverflow.com/questions/6525538/convert-utc-date-time-to-local-date-time | Last Update : Tue, 25 May 21

Answers related to javascript convert utc date time to local date time

Code Explorer Popular Question For Whatever