Date() 返回当日的日期和时间。
通过方法来获取
getDate() 从 Date 对象返回一个月中的某一天 返回几号的意思
getDay() 从 Date 对象返回一周中的某一天 返回周几的意思
getMonth() 从 Date 对象返回月份 月份+1
getFullYear() 从 Date 对象返回年份。
getYear() //getYear 是1900到现在年份的值
getHours() 返回 Date 对象的小时
getMinutes() 返回 Date 对象的分钟
getSeconds() 返回 Date 对象的秒数
getMilliseconds() 返回 Date 对象的毫秒 0-999
getTime() 返回 1970至今的总毫秒数。
toUTCString() 根据世界时 (UTC) 把 Date 对象转换为字符串
toDateString()可把 Date 对象的日期部分转换 //> Thu May 30 2019
toISOString()使用ISO标准将 Date 对象转换为字符串。 //>2019-05-29T20:45:11.786Z
toLocaleString()把数组转换为本地字符串。 //>2019/5/29 上午8:45:11
toTimeString()可把 Date 对象的时间部分转换为字符串//=> 07:45:11 GMT+0800 (中国标准时间
toLocaleTimeString() 根据本地时间把 Date 对象的时间部分转换为字符串,并返回结果==>//上午7:45:11
toLocaleDateString() 根据本地时间格式,把 Date 对象的日期部分转换为字符串。==>// 2019/5/30
js中Date 对象
最新推荐文章于 2024-04-26 21:45:00 发布