Shadab Mehdi
Shadab Mehdi

Reputation: 653

How to set specific start time in FlipClock js widget?

I want to set New York time in FlipClock.js widget along with moment.js. I have 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);

Upvotes: 3

Views: 1742

Answers (1)

Tony Miller
Tony Miller

Reputation: 9159

From the Moment Timezone documentation:

There are two interfaces for using time zones with Moment.js.

moment.tz(..., String) is used to create a moment with a time zone, and moment().tz(String) is used to change the time zone on an existing 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'
});

Upvotes: 2

Related Questions