Sorry if the title is a bit confusing. I stomp my head on the floor with time in NodeJS/ Javascript. I can get the current UTC time as follows:
var currentTime = Date.now();
I can get the current time for a user who, for example, is in the time zone -3as follows:
var offsetTime = Date.now() + (numTimeZone * 3600000);
But how do I get the user's local time, say, 6am, converted to UTC?
Practical application :
What I'm trying to do is create an auto-emailer that sends an email to the user at 6am local time. My server is in one time zone, and they will be in another, so I try to standardize it against UTC, so every minute I can set my server to check the time currentUTC, and then check that the 6am user time is converted to UTC ( local6am), and if currentUTC > local6amthen you should send an email.
What is the best way to achieve this? Preferably, if not using the library, if possible.
source
share