If I do a test for a minute it runs behind (my computer hits the minute mark before the script does).
I use a website to calculate the milliseconds to where I want the countdown to end, but I think this comes with a problem. Here is a Fiddle to show functionality.įtSeconds(futureDate.getSeconds() - 10) Ĭountdown calculate milliseconds I have a countdown script that allows me to count down to a certain time. Just add a check if the diff <= 0 then only run the countdown based on that condition.
$('.message').html('Our First Offer Has Ended!') Var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000 Calculate the difference in seconds between the future and current date Var futureDate = new Date("Novem14:20:00") I'm left with a visible clock displaying seemingly random negative numbers. Each instance seems to bypass the actual action of the clock stopping and thus the class isn't applied and the clock not hidden. visibility: hidden īut my issue arises if someone visits the page's URL after the countdown has ended or they alternatively refresh the browser page after the countdown has ended. I can use a callback of flipclock's stop:function to apply a brand new css class to the div housing the clock and have in my stylesheet a style matching that new class, that hides the clock - e.g. My issue is with when the countdown reached zero. Whether browsing the page in the UK or in the US or in Australia, the countdown will finish at the same GMT time worldwide. The page has within it a flipclockjs countdown that uses the server's time as it's "current date" compared to the "future date" for when the countdown is to finish.Īll so well and good so far. I currently have a dev PHP web page, which gains "live" time from its web server upon page load. In flipclock.js countdown, hiding the clock, even after a browser refresh - javascript thanks in advance.