I am really trying to find a decent working timer demo (countdown from x minutes) app for ionic 3 to use in my project but i am only finding outdated ones.
Tried installing ng2_countdown but seems like it is no longer updated and i cannot install it. Anyone know a working source?
Check this repo out https://github.com/yannbf/ionic3-components , he has created a number of custom and experimental ionic3 components, i noticed that he has a countdown timer component, you can have a look there as well, good luck!
let countDownDate = new Date("Oct 29, 2018 14:50:25").getTime();
// Update the count down every 1 second
let x = setInterval(function () {
// Get todays date and time
let now = new Date().getTime();
// Find the distance between now and the count down date
let distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
let days = Math.floor(distance / (1000 * 60 * 60 * 24));
let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((distance % (1000 * 60)) / 1000);
console.log(now, "now", "countDownDate", countDownDate, "distance", distance, "days", days);
// Output the result in an element with id="demo"
document.getElementById("demo").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);