I'm trying to do a countdown timer in JavaScript, using countdown, but I want the Date object to be relative to a particular time zone.
How can I make sure that my countdown is relative to a specific time/date in a specific time zone?
I'm trying to do a countdown timer in JavaScript, using countdown, but I want the Date object to be relative to a particular time zone.
How can I make sure that my countdown is relative to a specific time/date in a specific time zone?
As shown in the example of countdown plugin (http://hilios.github.io/jQuery.countdown/examples/timezone-aware.html), you need to add MomentJS library to set Date object relative to a particular time zone.
HTML:
<div id="clock"></div>
JS:
var nextYear = moment.tz("2015-08-22 00:00", "America/Sao_Paulo");
$('#clock').countdown(nextYear.toDate(), function(event) {
$(this).html(event.strftime('%D days %H:%M:%S'));
});
JSFiddle: https://jsfiddle.net/kbk798py/