FFIVE
2023-08-10 10:55:45
是否可以制作 time.getSeconds(); 向下而不是向上?var time = new Date();var time2 = time.getSeconds();console.log(time2)
3 回答

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

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

MMTTMM
TA貢獻(xiàn)1869條經(jīng)驗 獲得超4個贊
var time = new Date();
var time2 = time.getSeconds();
const output = 60 - time2;
console.log(output)
添加回答
舉報
0/150
提交
取消