JavaScript 日期
创造 date 函数
- new Date()
- 当前日期和时间创建先的日期对象
- new Date( year,month,day,hours,minutes,seconds,milliseconds)
- 指定日期和时间创建先的日期对象
- 月份从 0-11
- 6 -2 个参数
- 6个参数:全部包含、
- 5 个参数:年月日小时和分钟、
- 四个参数:年月日小时,
- 如果只提供一个参数,将其视为毫秒
- year 这个参数如果是一位或 2 位,默认是 1900 年开头
- new Date(milliseconds)
- 创建一个临 时加毫秒的新日期对象
- 可以为负数,则表 示 1970 年以前的日期
- new Date(date string)
- toUTCString()
- 将日期装换为 UTC 字符串
- toDateString()
- 将日期转化为更为易读的格式
日期获取方法
- getDate()
- getDay()
- getFullYear()
- getHours()
- getMilliseconds()
- getMinutes()
- getMonth()
- getSeconds()
- getTime()
日期设置方法
- setDate()
- setFullYear()
- setHours()
- setMilliseconds()
- setMinutes()
- setMonth()
- setSeconds()
- setTime()