Code Monkey home page Code Monkey logo

Comments (4)

hilios avatar hilios commented on September 17, 2024

Well your problem isn't really a countdown problem, in fact is a problem of JavaScript that will always parse the date according to the user computer date.

Answering your question directly, if work on your server side to handle the timezone correctly and send to the script the milliseconds to the UTC you can manage this issue, but if the user change his machine date if could lead to a mismatch, but look, you CAN'T avoid-it.

But you could actually validate if the user machine date is the same from the server comparing the the milliseconds to the UTC, and give a warning or do any kind of calculation.

If you think about your problem and see that have some place for improvement of the script just let me know, ok?

from jquery.countdown.

KelsoField avatar KelsoField commented on September 17, 2024

Thank you for the quick reply
Indeed, I know and understand the issue as JS is client side.
Changing user time is beyond any control, but the ability to define (NOW) and use php to place the unix timestamp would be useful.
I cannot see anything n the documentation to define "now" in unix form.
Having a
setNow: "VALUE" ,
that overrides the JS default from within the script would be very handy.

from jquery.countdown.

hilios avatar hilios commented on September 17, 2024

Today I was thinking about your proposal, and notice that is impossible to implement it. Lets talk about history...

In a earlier version of the script I used to calculate seconds span of from the start to end date at the script initialisation, after that a 1 second interval was started.

This implementation caused a bug that hangup the script 2 second earlier (see issue #10) hence you could start the countdown 0.3 sec (or 300 ms) to finishes and still the script would wait 1 second to update it's status, this delay is unacceptable in certain cases like an auction site.

So the algorithm changed to work on a precision range that can be adjustable, and prevent at best some of this cases.

This version uses new Date() to get the current machine time, and recalculate the interval of the script (see line 167 of src), and this is needed in order to know when the time changed, setting a fixed setNow wouldn't add any precision and would lead back to the issue mentioned above.

from jquery.countdown.

triplef avatar triplef commented on September 17, 2024

Can’t you just pass something like the following as the target date parameter?

new Date(Date.UTC(2014, 4, 19, 11, 0, 0))

from jquery.countdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.