2019-10-23 日期操作

93 阅读1分钟

日期操作

  1. new Date().getMonth() 得到的月份是从0开始的
  2. new Date(year, month, day)
// Thu Oct 31 2019 00:00:00 GMT+0800,这个getMonth(),得到的是9(0起始)
new Date(2019, 10, 0)
// Fri Nov 01 2019 00:00:00 GMT+0800,这个getMonth(),得到的是10(0起始)
new Date(2019, 10, 1)
  1. 获取的是month月(从1开始)的最大天数new Date(year, month, 0).getDate()