Tips
yyyy-mm-dd 向前取一个月时间 (传入参数是 yyyy-mm-dd 字符串 返回值同)
function getPreMonth(date) { var arr = date.split('-'); var year = arr[0]; var month = arr[1]; var day = arr[2]; var days = new Date(year, month, 0); days = days.getDate(); var year2 = year; var month2 = parseInt(month) - 1; if (month2 == 0) { year2 = parseInt(year2) - 1; month2 = 12; } var day2 = day; var days2 = new Date(year2, month2, 0); days2 = days2.getDate(); if (day2 > days2) { day2 = days2; } if (month2 < 10) { month2 = '0' + month2; } var t2 = year2 + '-' + month2 + '-' + day2; return t2; }
yyyy-mm-dd 转时间戳
var time = Date.parse(new Date("2019-11-27")) / 1000;
判断时间跨度 st en (伪代码)
(en - st) compare with (86400 * days)