3 回答

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊
你可以這樣做:
var secondsInMinute = 60;
var time = new Date();
var time2 = secondsInMinute - time.getSeconds();
console.log(time2)

TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊
Ciao,您可以將自己的函數(shù)添加到 Date 原型(稱為getMySeconds)以反向方式獲取秒數(shù),如下所示:
Date.prototype.getMySeconds = function () {
return (60 - this.getSeconds());
}
var time = new Date();
var time2 = time.getMySeconds();
console.log(time2)

TA貢獻(xiàn)1869條經(jīng)驗(yàn) 獲得超4個(gè)贊
var time = new Date();
var time2 = time.getSeconds();
const output = 60 - time2;
console.log(output)
添加回答
舉報(bào)