Skip to content

new Date() 获取当前客户端本地的日期,结果是一个日期对象 客户端时间可以肆意更改,不能拿它做重要的业务判断

new Date([时间字符串]) -> 把一个时间字符串变为标准的日期对象 yyyy/mm/dd hh/mm/ss yyyy/mm/dd ...

getFullYear 获取年 4位
let time = new Date() time.getFullYead() getMonth 获取月 0-11 代表 1-12月 getDate 获取日 getHours 获取小时 getMinutes 获取分 getSeconds 获取秒 getMilliseconds 获取毫秒 getDay 获取星期 0-6 代表周日-周六 getTime 距离1970-01-01 00:00:00之间的毫秒差