获取本月1日日期
//获取本月1日日期 function getMon() { var today = new Date(); var tYear = today.getFullYear(); var tMonth = today.getMonth(); tMonth = doHandleMonth(tMonth + 1); return tYear + "-" + tMonth + "-" + '01'; }
获取当前日期前后的时间
/**获取近N天*/ function getRecentDay(day) { var today = new Date(); var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day; today.setTime(targetday_milliseconds); var tYear = today.getFullYear(); var tMonth = today.getMonth(); var tDate = today.getDate(); tMonth = doHandleMonth(tMonth + 1); tDate = doHandleMonth(tDate); return tYear + "-" + tMonth + "-" + tDate; } function doHandleMonth(month) { var m = month; if (month.toString().length == 1) { m = "0" + month; } return m; }
lockdatav done!