当前位置:网站首页>Date对象简介
Date对象简介
2022-07-22 09:04:00 【请叫我杰拉德6】
Date对象,在js中使用Date对象来表示一个时间
创建一个Date对象,如果直接使用构造函数创建一个Date对象,则会封装为当前代码执行的时间
var d = new Date()
创建一个指定时间的对象,需要在构造函数中传递一个表示时间的字符串作为参数
日期的格式: 月份/年/ 时:分:秒
var d = new Date("12/03/2020 10:10:10");
Date()对象的方法
1.getDate()获取当前日期对象是几日
2.getDay()获取当前日期对象是周几,会返回一个0~6的值,0表示周一,1表示周二,以此类推…
3.getMonth()获取当前时间对象的月份,会返回一个0~11的值,0表示一月,1表示二月,以此类推…
4.getFullYear()获取当前日期对象的年份
5.getTime()获取当前日期对象的时间戳,时间戳,指的是从格林威治标准时间的1970年1月1日,0时0分0秒,到当前日期所花费的毫秒数(1秒 = 1000毫秒),由于年,月,日的时间进制都不统一,所以计算机为了统一时间进制,在底层保存时间时使用都是毫秒戳
6.now()获取当前代码执行时的时间戳,常用于测试代码运行时间
边栏推荐
- 3. Transbot modifies the display resolution
- [10:00 public class]: cloud video conference system privatization practice
- 计算机网络学习笔记7-TCP编程流程及面试题
- Geowebcache publishes ArcGIS slice data
- DistSQL 深度解析:打造动态化的分布式数据库
- charm zaza functional test (by quqi99)
- QT笔记——实现窗体自适应
- 二、注解
- Thread learning notes
- Fabric. JS control element level
猜你喜欢
Installation and introduction of Lin UI component library of wechat applet - Advanced
QT笔记——自定义数据类型
It took two hours to find the bug about scrollto scrolling the distance from offsettop to the top
【10点公开课】:云视频会议系统私有化实践
Dr. water
QT笔记——eventFilter事件过滤器
Android互联网大厂面试经验
QT notes - drag lines and movement of qtablewidget
【Rust】我该用什么软件开发 Rust | 常用支持 Rust 的编辑器推荐
double类型不能进行精确计算的问题
随机推荐
Qt Notes - nombre de lignes traînées et de mouvements pour le Widget qtablewidget
Fabric.js 控制元素层级
[标准规范] 低代码的概念和定义到底是什么?无代码是否属于低代码?
力扣解法汇总324-摆动排序 II
Fabric. JS centered element
Jinan Zhangqiu subject three data collection
C # entry series (XXVII) -- Brief Analysis of LINQ
QT笔记——自定义数据类型
女嘉宾报名
Industrial Internet security situation prediction method integrating attention mechanism and bsru
43. String multiplication
MySQL密码正确但是启动报错Unable to create initial connections of pool.Access denied for user ‘root‘@‘localhost
Research on vulnerability identification technology for project version differences
2、 Notes
2.树莓派系统备份
【Rust】为什么我建议你学一下 Rust | Rust 初探
MySQL密碼正確但是啟動報錯Unable to create initial connections of pool.Access denied for user ‘root‘@‘localhost
关于scrollTo滚动offsetTop到顶部的距离的bug找了两个小时
小程序实现列表和详情页
力扣解法汇总1108-IP 地址无效化