Javascript 时间相关的函数和操作

var nowDate = new Date();
nowDate.getDate(): 22
nowDate.getTimezoneOffset(): -480
nowDate.toDateString(): "Thu Oct 22 2020"
nowDate.toGMTString(): "Thu, 22 Oct 2020 06:32:19 GMT"
nowDate.toISOString(): "2020-10-22T06:32:19.787Z"
nowDate.toLocaleDateString(): "2020/10/22"
nowDate.toLocaleString(): "2020/10/22 下午2:32:19"
nowDate.toLocaleTimeString(): "下午2:32:19"
nowDate.toString(): "Thu Oct 22 2020 14:32:19 GMT+0800 (中国标准时间)"
nowDate.toTimeString(): "14:32:19 GMT+0800 (中国标准时间)"
nowDate.toUTCString(): "Thu, 22 Oct 2020 06:32:19 GMT"
nowDate.constructor(): "Thu Oct 22 2020 14:37:23 GMT+0800 (中国标准时间)"
nowDate.toLocaleDateString()+" "+nowDate.toTimeString().split(' ')[0]: "2020/10/22 14:32:19"
前一天(前后天或者时分秒皆可用)
new Date(nowDate.getTime()-(1000*60*60*24)).toLocaleString(): "2020/10/21 下午2:32:19"

 

posted @ 2020-10-22 14:47  厚颜无耻之徒  阅读(124)  评论(0编辑  收藏  举报