How to set specific start time in FlipClock js widgets?

I want to set the time in New York in a FlipClock.js

widget along with moment.js

. I tried with

HTML
<div class="my_flip_clock"></div>

JS
var a = moment.tz('America/New_York');
var clock = $('.my_flip_clock').FlipClock({
    clockFace: 'TwelveHourClock'
});
clock.setTime(new Date(a.format()).getTime() / 1000);

      

+3


source to share


1 answer


From the Moment Timing Documentation :

There are two interfaces for using timezones with Moment.js.



moment.tz (..., String) is used to create moment with timezone and moment (). tz (String) is used to change the time zone at the present moment.

var d = new Date(); // Get a new JS Date instance at current time in system time zone
var a = moment.tz(d.getTime(), 'America/New_York');  // Convert to New York time zone
var dny = new Date(a.format('YYYY-MM-DD hh:mm:ss a')); // Get new JS Date instance for values in New York
var clock = $('.my_flip_clock').FlipClock(dny, {
    clockFace: 'TwelveHourClock'
});

      

+2


source







All Articles