I use the following code to get the current UTC time in the correct format, but the client came back and asked for the timestamp to be in EST instead of UTC. I searched google and stackoverflow but cannot find an answer that works with my existing code.
var currentdate = new Date();
var datetime = currentdate.getFullYear() + ":"
+ ("0" + (currentdate.getUTCMonth()+1)).slice(-2) + ":"
+ ("0" + currentdate.getUTCDate()).slice(-2) + ":"
+ ("0" + currentdate.getUTCHours()).slice(-2) + ":"
+ ("0" + currentdate.getUTCMinutes()).slice(-2) + ":"
+ ("0" + currentdate.getUTCSeconds()).slice(-2);
What we are trying to do is set a constant timestamp for EST regardless of where the browser is in the world, therefore, UTC is originally used.
Thanks!
source
share