Very simple question. I've got a NodeJS application using countdown (https://www.npmjs.com/package/countdown). The countdown itself works.
However, I don't know how to set it to 8 minutes?
The command is:
countdown( new Date(2000, 0, 1) ).toString();
I've tried, but I don't get it to less than 47 years. I'm new to all of this. Could anyone help? Feel like this is a very stupid question, but yeah... Yes, I've read the documentation.
The countdown is supposed to count down 8 minutes from the moment it's run. It's not supposed to run from a fixed dated until a fixed date.
You need to create a Date
object that is 8 minutes in the future.
You can create one based on the current date, and then use setMinutes
to increase that by 8 minutes:
let later = new Date();
later.setMinutes(later.getMinutes() + 8);
countdown(
later,
function(ts) {
document.getElementById('pageTimer').innerHTML = ts.toHTML("strong");
},
countdown.HOURS|countdown.MINUTES|countdown.SECONDS);
<script src="https://cdnjs.cloudflare.com/ajax/libs/countdown/2.6.0/countdown.js"></script>
<span id="pageTimer"></span>