JS(05)-
Date 对象用于处理日期和时间
var 日期对象=new Date(参数)
参数格式:MM DD,YYYY,hh:mm:ss
示例:
①var today=new Date(); //返回当前日期和时间
②var tdate=new Date("9 1,2022,14:38:12"); //返回指定时间,注意时间不要有空格。
Date常用方法
getDate() 返回 Date 对象的一个月中的每一天,其值介于1~31之间
getDay() 返回 Date 对象的星期中的每一天,其值介于0~6之间(注:0-周日)
getHours() 返回 Date 对象的小时数,其值介于0~23之间
getMinutes() 返回 Date 对象的分钟数,其值介于0~59之间
getSeconds() 返回 Date 对象的秒数,其值介于0~59之间
getMonth() 返回 Date 对象的月份,其值介于0~11之间(注:0-1月份)
getFullYear() 返回 Date 对象的年份,其值为4位数
函数封装&三部运算符方法写出当前时间
(function是一等公民,实现先定义,后执行,代码正常运行)
时间戳
3天之后星期几
steDate 通过设置日期来改变日期对象
用数字类型 也就是逗号写更容易