更新时间:2023-11-23 21:46:04
getMonth
返回0到11的月份,其中0代表一月,11代表十二月。 getDay
返回星期几0-6,其中0代表星期日,6代表星期六。因此,日志:
getMonth
returns the month from 0-11, where 0 represents January and 11 represents December. getDay
returns Day of the week 0-6, where 0 represents Sunday and 6 represents Saturday. So, the log:
returnDate(1): 11.0 / 2.0 / 2020.0
是正确的并表示
returnDate(1): Dec / Tue / 2020.0
Tue Dec 01 2020 00:00:00 GMT-0500 (Eastern Standard Time)
使用 Intl
:
console.info(new Intl.DateTimeFormat().format(returnDate))
或
console.log("returnDate(1):", returnDate.getMonth()+1, "/" , returnDate.getDate(), "/", returnDate.getFullYear());//Note Date vs Day and "+1"