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