1. 程式人生 > >js 時間類函數

js 時間類函數

gety cond gettime wid body minutes 12月 day hour

js 時間類是 Date()

var currtime = new Date();// 實例一個時間,是當前時間

獲取時間的各部分的方法如下:

.getYear() 兩位數的年份
.getFullYear()

四位數年份

.getMonth() 月分 0-11,如果按1-12月算,應該加1 [ getMonth()+1 ]
.getDate() 幾號
.getDay() 星期幾 0-6 0是星期日,
.getTime() 從1970年1月1日開始到現在的毫秒數
.getHours() 幾點 0-23
.getMinutes() 幾分 0-59
.getSeconds() 幾秒 0-59
.getMilliseconds() 幾毫秒 0-999














js 時間類函數