Within my JavaScript object, I have the following information:
var dateobj = {
date: "2020-12-21 03:31:06.000000",
timezone: "Africa/Abidjan",
timezone_type: 3
}
var date = new Date();
var options = {
timeZone: dateobj.timezone
};
var curr_date = date.toLocaleString('en-US', options)
console.log(curr_date)
//I desire to
//diff = curr_date - dateobj.date
I am looking to calculate the time difference in hours between the current date-time and the specified timezone. While I understand that toLocaleString()
can be used to obtain the date-time string in a specific timezone, I am unsure how to determine the time difference. The provided code retrieves the current date time within the timezone, but how do I go about calculating the time difference in hours?