flipcountdown icon indicating copy to clipboard operation
flipcountdown copied to clipboard

beforeDateTime and tzoneOffset

Open AlexanderSk opened this issue 10 years ago • 1 comments

Hello,

I can you please check, support the option tzoneOffset along beforeDateTime.

Currently these two scripts show the exact same time.

$('#retroclockbox1').flipcountdown({ beforeDateTime:'10/20/2015 11:00:00', tzoneOffset: 2 });

$('#retroclockbox2').flipcountdown({ beforeDateTime:'10/20/2015 11:00:00', tzoneOffset: 3 });

I found a few time in order to fix it and i came with the following modification: Line 187 options.beforeDateTime = Math.round((new Date(options.beforeDateTime)).getTime()/1000);

I placed for a test...

if(options.tzoneOffset){ //get current local time var tmp = new Date(options.beforeDateTime).getTime(); //get current local time offset var localoffset = new Date(options.beforeDateTime).getTimezoneOffset(); //find the difference between offsets var offsetdif = ( (options.tzoneOffset * 60) + localoffset ) / 60; //place the date in a var tmp = (new Date(options.beforeDateTime)).getTime() - 3600000 * (offsetdif) options.beforeDateTime = Math.round(tmp/1000); }else{ options.beforeDateTime = Math.round((new Date(options.beforeDateTime)).getTime()/1000); }

This covers the string and not the object case of course... but is is something :) Unfortunately there is no easy way in javascript to convert a date into specific timezoneoffset.

Thank you for your time!

Edit: 6-10-2015.

AlexanderSk avatar Oct 01 '15 10:10 AlexanderSk

how to stop countdown?

filipemontt avatar Oct 29 '17 01:10 filipemontt