创建
一般就是不传参数实例化
let time = new Date();
console.log(time) //中国标准时间的 星期 月 日 年 时:分:秒
获取星期几(0-6)0表示星期天
time.getDay()
获取年份
time.getFullYear()
获取月份 (0-11) 0表示12月
time.getMonth
获取日期(1-31)
time.getDate()
获取时间的四个方法
时:time.getHours()
分:time.getMinutes()
秒:time.getSeconds()
毫秒:time.getMilliseconds()
获取现在到1970年1月1日0时0分0秒的毫秒数()(UTC)
time.getTime() 返回一个值 单位为毫秒
Date.now()
计算指定时间的到1970年1月1日0时0分0秒的毫秒数
Date.parse() 参数就是时间格式
将对象转换为字符串型
time.toString()
使用typeof 检测 time后 time为string类型
浙公网安备 33010602011771号