詳解JavaScript中setSeconds()方法的使用
javascript Date.setSeconds()方法按照本地時間的設(shè)置秒指定日期。
語法
Date.setSeconds(secondsValue[, msValue])
注:括號內(nèi)外的數(shù)據(jù)是可選的
下面是參數(shù)的詳細信息:
- secondsValue : 0到59之間的整數(shù)。
- msValue : 一個數(shù)字在0和999之間,表示毫秒。
如果不指定msValue參數(shù),使用從方法使用getMilliseconds返回的值。如果指定的參數(shù)是預(yù)期范圍之外,調(diào)用setSeconds嘗試相應(yīng)地更新Date對象的最新信息。例如,如果使用secondsValue的值為100,存儲在日期對象的分鐘將加1,40將用于秒。
返回值:
- NA
例子:
<html> <head> <title>JavaScript setSeconds Method</title> </head> <body> <script type="text/javascript"> var dt = new Date( "Aug 28, 2008 23:30:00" ); dt.setSeconds( 80 ); document.write( dt ); </script> </body> </html>
這將產(chǎn)生以下結(jié)果:
Thu Aug 28 23:31:20 UTC+0530 2008
相關(guān)文章
關(guān)于javascript中的typeof和instanceof介紹
typeof用來檢測給定變量的數(shù)據(jù)類型 instanceof用來檢測對象的類型2012-12-12Javascript中的數(shù)學(xué)函數(shù)集合
Javascript中的數(shù)學(xué)函數(shù)集合...2007-05-05javascript基礎(chǔ)之數(shù)據(jù)類型詳解
這篇文章主要介紹了如何理解JavaScript中的數(shù)據(jù)類型,幫助大家更好的學(xué)習JavaScript,感興趣的朋友可以了解下2021-11-11