由于JS运行环境不同(JS引擎),导致苹果设备(ios/mac)对相关时间的处理没有达到预期
windows/android 能识别 yyyy-mm-dd 的时间格式
mac/ios/火狐 只能识别 yyyy/mm/dd 的时间格式
所以在使用new Date()处理时间时,对不同的设备要进行区分
let time = '2022-09-05'
windows/android : new Date(time)
ios/mac : new Date(time.replace(/-/g, '/'))
浅析new Date()
new Date() - 可以得到一个时间对象 - Mon Sep 05 2022 00:32:47 GMT+0800 (中國標準時間)
new Date().getFullYear() - 2022
new Date().getMonth() - 8
new Date().getDate() - 5
new Date().getDay() - 1 - 周几
new Date().getHours() - 0
new Date().getMinutes() - 34
new Date().getSeconds() - 14
浅析Date.parse()
`Date.parse()`函数用于分析一个包含日期的字符串,并返回该日期与 1970 年 1 月 1 日午夜之间相差的毫秒数。