当前位置:网站首页>js时间函数大全 详细的讲解 -----阿浩博客
js时间函数大全 详细的讲解 -----阿浩博客
2022-07-06 09:29:00 【冯浩(grow up)】
日期、时间对象
日期、时间对象是用来保存日期时间的,以特定的时间段保存时间,从1970年向前或者向后推285616年,UTC是格林尼治时间,又称世界统一时间。
实例化日期对象:var date = new Date ( );
一年的时间戳:var yearTimeStamp = 3652460601000;
设置日期时间 var date = new Date ( 2018,1,1 )
var date = new Date(“1/1/2018 11:30:30”);
1、组件方法
1、获取满年 getFullYear ( );
2、设置满年 setFullYear ( );
3、获取月份 getMonth ( ); 取值范围:0-11
4、设置月份 setMonth ( );
5、获取日期 getDate ( ); 取值范围:1-31
6、设置日期 setDate ( );
7、获取星期 getDay ( ); 取值范围:0-6
8、获取小时 getHours ( ); 取值范围:0-23
9、设置小时 setHours ( );
10、获取分钟 getMinutes ( ); 取值范围:0-59
11、设置分钟 setMinutes ( );
12、获取秒 getSeconds ( ); 取值范围:0-59
13、设置秒 setSeconds ( );
14、获取毫秒 getMillionSeconds ( ); 取值范围:0-999
15、设置毫秒 setMillionSeconds ( );
组件方法都有一个对应的UTC。
函数:获取指定年月的第一天是星期几
function getweek(year,month){
return new Date(year,month-1).getDay;
}console.log(getweek(2017,10));
2、时间定时器
1、设置时间定时器 setInterval ( function ( ){ },时间间隔(以毫秒计) );
2、清除时间定时器 clearInterval ( 定时器名称 );
边栏推荐
猜你喜欢

Borg maze (bfs+ minimum spanning tree) (problem solving report)

Codeforces Round #799 (Div. 4)A~H

Codeforces Round #801 (Div. 2)A~C

Problem - 922D、Robot Vacuum Cleaner - Codeforces

MariaDB的安装与配置

去掉input聚焦时的边框

Flag framework configures loguru logstore

QT实现窗口渐变消失QPropertyAnimation+进度条

Maximum product (greedy)

Li Kou: the 81st biweekly match
随机推荐
Codeforces Round #798 (Div. 2)A~D
1005. Maximized array sum after K negations
7-1 understand everything (20 points)
Determine the Photo Position
QT implementation fillet window
Raspberry pie 4b64 bit system installation miniconda (it took a few days to finally solve it)
Alice and Bob (2021 Niuke summer multi school training camp 1)
读取和保存zarr文件
Vs2019 initial use
921. Minimum additions to make parentheses valid
Input can only input numbers, limited input
D - function (HDU - 6546) girls' competition
2027. Minimum number of operations to convert strings
Basic Q & A of introductory C language
<li>圆点样式 list-style-type
Opencv learning log 29 -- gamma correction
QT implementation window gradually disappears qpropertyanimation+ progress bar
Effet d'utilisation, déclenché lorsque les composants de la fonction sont montés et déchargés
Pytorch extract skeleton (differentiable)
Oneforall installation and use