创建当前的对象实例,不带任何参数 let today = new Date(“可以填时间”) 创建当前时间戳的日期时间对象实例,参数是时间戳
时间戳:
指的是某一个时间距离 1970年1月1日0时0分0秒过去了 多少毫秒值 1秒 = 1000毫秒
可以指定多个时间 顺序为年、月、日、时、分、秒, 其中 年、月、日 是必须的
let timer = new Date(2005+100,4,25,10,20,0)
返回指定时间的方法
- Date.getDate() 返回一个月中的某一天
- Date.getDay() 返回一周中的某一天
- Date.getFullYear() 返回Date对象的年份
- Date.getHours() 返回Date对象的小时
- Date.getMilliseconds() 返回返回Date对象的毫秒
- Date.getMinutes() 返回Date对象的分钟
- Date.getMoth() 返回Date对象的月份
- Date.getSeconds() 返回Date对象的秒
- Date.getTime() 返回Date对象的毫秒