0

現在と現在の差を +120 秒表示する必要があります。分単位ではなく、秒単位で違いを比較する必要があります。コードは次のようになります

 this.nextDate = moment().add(120, 'seconds');

 this.timer = setInterval(() => {
     this.currentDate = moment();
     this.diff = moment.duration(this.nextDate.diff(this.currentDate));    
 }, 1000)   

問題: Console.log(this.diff.seconds())は、差が 120 秒ではなく 60 秒 (および減少) であることを返します。

だから問題は何ですか?moment.jsが 120 秒にならないのはなぜですか?

4

1 に答える 1