Is there a way to create a countup timer in Angular starting from a specific number of seconds? Also, I would like the format to be displayed as hh:mm:ss if possible.
I attempted to accomplish this by utilizing the getAlarmDuration function within the template with a duration specified in seconds.
getAlarmDuration(duration: number): any {
this.countStart = duration;
setInterval(this.setTime, 1000);
}
setTime(): void {
++this.countStart;
console.log(this.pad(parseInt((this.countStart / 60).toString(), 10)) + ':' + this.pad(this.countStart % 60))
}
pad(val: any): string {
var valString = val + "";
if (valString.length < 2) {
return "0" + valString;
}
else {
return valString;
}
}
Any help is greatly appreciated. Thank you.