Angular 4 display current time

前端 未结 6 1612
青春惊慌失措
青春惊慌失措 2021-02-02 11:44

What is the correct (canonical) way to display current time in angular 4 change detection system?

The problem is as follows: current time changes constantly, each mome

6条回答
  •  别那么骄傲
    2021-02-02 12:09

    CurrentTime: any;
      constructor() {
        setInterval(() => {
          this.CurrentTime = new Date().getHours() + ':' + new Date().getMinutes() + ':'+  new Date().getSeconds()}, 1);
      }
    

提交回复
热议问题