0

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?

Moshe
  • 57,511
  • 78
  • 272
  • 425
  • depends on source and type of initial date value. Please expand on use case – charlietfl Aug 21 '15 at 17:17
  • 1
    Maybe this could help: http://www.techrepublic.com/article/convert-the-local-time-to-another-time-zone-with-this-javascript/6016329/ – VVV Aug 21 '15 at 17:19
  • Fiddle : http://jsfiddle.net/GEpaH/ – VVV Aug 21 '15 at 17:20
  • Take a look at http://stackoverflow.com/questions/15141762/how-to-initialize-javascript-date-to-a-particular-timezone – Zakaria Acharki Aug 21 '15 at 17:21
  • You need to add momentJS library along with this. Check this example of plugin: http://hilios.github.io/jQuery.countdown/examples/timezone-aware.html – Chitrang Aug 21 '15 at 17:23

1 Answers1

0

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/

Chitrang
  • 2,079
  • 1
  • 16
  • 18