I have this function to get the time the user is authenticated and it is running on the login button if the data entered is valid. I wanted to use that "this.time" in many different components of the application to show the user authentication time, but I don't know how to do that since the value of "this.time" is not static, could someone help me please? How do I get that value to other components?
public sec = 0;
public min = 0;
public hour = 0;
public time: string;
startStopWatch() {
this.time = "00:00:00";
setInterval(() => {
console.log(this.time)
this.sec++;
this.time = (this.hour + ':' + this.min + ':' + this.sec);
if (this.sec === 60) {
this.min++;
this.sec = 0;
if (this.min === 60) {
this.hour++;
this.min = 0;
}
}
}, 1000);
}