当前位置:网站首页>JS time function Daquan detailed explanation ----- AHAO blog

JS time function Daquan detailed explanation ----- AHAO blog

2022-07-06 16:39:00 Feng Hao (grow up)

date 、 Time object
date 、 Time object is used to save date and time , Save time in a specific time period , from 1970 Year forward or backward 285616 year ,UTC It's Greenwich mean time , Also known as universal time .
Instantiate Date object :var date = new Date ( );
Timestamp of one year :var yearTimeStamp = 3652460601000;

Set date time var date = new Date ( 2018,1,1 )
var date = new Date(“1/1/2018 11:30:30”);
1、 Component method

1、 Get full year getFullYear ( );
2、 Set full year setFullYear ( );
3、 Get month getMonth ( ); Value range :0-11
4、 Set month setMonth ( );
5、 Get date getDate ( ); Value range :1-31
6、 Setting date setDate ( );
7、 Get week getDay ( ); Value range :0-6
8、 For hours getHours ( ); Value range :0-23
9、 Set hours setHours ( );
10、 Get minutes getMinutes ( ); Value range :0-59
11、 Set minutes setMinutes ( );
12、 Get seconds getSeconds ( ); Value range :0-59
13、 Set seconds setSeconds ( );
14、 Get milliseconds getMillionSeconds ( ); Value range :0-999
15、 Set milliseconds setMillionSeconds ( );
Component methods have a corresponding UTC.

function : Get the day of the week on the first day of the specified year
function getweek(year,month){
return new Date(year,month-1).getDay;
}console.log(getweek(2017,10));

2、 Time timer
1、 Set time timer setInterval ( function ( ){ }, The time interval ( In milliseconds ) );

2、 Clear time timer clearInterval ( Timer name );

原网站

版权声明
本文为[Feng Hao (grow up)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060920252477.html