I'm setting up a code for a timer and I need to have the currentTime
in the correct timezone. I have therefore to different codes
. One code
with the correct currentTime
and the other code
that is only doing local
time. I am trying to add the code
that has the correct timezone
in to the other code
but I can't get it work.
Here is the code
with timezone
:
var $ = window.jQuery;
var setTime = function(){
var date = moment().tz("Europe/Paris");
var day = date.day();
console.log('date', date);
console.log('day', day);
var time = date.format("h:mm A");
console.log(time, time);
$('#current-time').html("Current time: " + time + " ");
};
setTime();
And here is the code
wit local time.
var current = new Date();
var day = current.getDay();
var currentTime = (currentTime) = (current.getHours() * 60) + current.getMinutes();
var remainTime = 0;
var closeTime = (openTime[day].close *60);
var openTime = (openTime[day].open *60);