Giter Club home page Giter Club logo

Comments (3)

objectivehtml avatar objectivehtml commented on June 1, 2024

I just tested this exact example for 5 minutes, and mine was only a few seconds behind. I noticed my clock didn't get out of sync until I left one browser to in the background and did other stuff while the clock runs... I am not sure what would cause this considering I am using the system time and just passing the number of seconds that have passed to the clock, and it just performs a flip. It's almost as if this is a cpu/browser issue. I am not sure how to fix it off the top of my head.

from flipclock.

davidhan527 avatar davidhan527 commented on June 1, 2024

Hi Justin,

I love your app by the way.

I'm going to have to resort to the most accurate option. Here is what I
found. The code below is a simple countdown timer that runs an interval and
constantly finds the current time difference and refreshing the html.

I hope this helps in some way. Thanks for your reply.

window.onload = function() {

var minutes, seconds;

var countdown = document.getElementById("countdown");
var target_date = new Date(new Date().getTime() + (25*60000))

setInterval(function () {

var current_date = new Date()

var seconds_left = (target_date - current_date.getTime()) / 1000;

minutes = parseInt(seconds_left / 60);
seconds = parseInt(seconds_left % 60);

// format countdown string + set tag value
countdown.innerHTML = minutes + "m, " + seconds + "s";
}, 1000);

};

from flipclock.

objectivehtml avatar objectivehtml commented on June 1, 2024

That's pretty much the same thing I do. At this point I will just keep an eye on this, because I am not sure how to fix it. If anyone else has any insight, just let me know.

from flipclock.

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.