How would i make users be able to input minutes to change the countdown time?


I would like to be able to make users choose how many minutes the timer should countdown for, what should I change/add to this script? BTW I have no prior experience in Javascript and I’m learning right now, so please keep that in mind! Any help is MUCH appreciated. This is a timer that should count down minutes, this is the design I have done in html and css: Pomodorotimerdesign I want the users to enter a "work time" and a "break time" so that the timer counts down the work time and when thats done it automatically counts down the break time and repeat. As i said earlier this is my first "js project" so any help is much needed and appreciated!

var countDownDate = new Date("Oct 16, 2021 20:37:25").getTime();

var x = setInterval(function() {

  var now = new Date().getTime();

  var distance = countDownDate - now;

  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);

  document.getElementById("demo").innerHTML = minutes + "m " + seconds + "s ";

  }
}, 1000);
</script>

Source: JavaSript – Stack Overflow

October 16, 2021
Category : News
Tags: countdown | javascript | timer | user-input

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.