惯例直接上代码:
1 //默认投保日期起,默认3天内的 2 function start() { 3 var today = new Date(new Date() - 2 * 24 * 60 * 60 * 1000); 4 var h = today.getFullYear(); 5 var m = today.getMonth() + 1; 6 var d = today.getDate(); 7 m = m < 10 ? "0" + m : m; 8 d = d < 10 ? "0" + d : d; 9 return h + "-" + m + "-" + d + " 00:00:00";10 }
获取就是当前时间算起,3天前凌晨0点0分0秒的日期