标签:gety instance time 间隔 int val logs eof 区间
/** * 以startDate为开始日期,计算时隔days天之后 的日期区间 * @param startDate 开始日期 * @param days 时间间隔天数 */ function getDateInterval(startDate, days) { var start; var end; if (startDate instanceof Date) { start = startDate.getFullYear() + "/" + (startDate.getMonth() + 1) + "/" + startDate.getDate(); var startAfterDays = startDate.setDate(startDate.getDate() - days); startAfterDays = new Date(startAfterDays); end = startAfterDays.getFullYear() + "/" + (startAfterDays.getMonth() + 1) + "/" + startAfterDays.getDate(); } return end + "~" + start; } /** * 获得昨天的日期 * @returns {Date} */ function getYesterdayDate() { var date = new Date(); date.setTime(date.getTime() - 24 * 60 * 60 * 1000); return date; } /** * 根据时间间隔天数,获取具体日期区间 * @param days 时间间隔天数 * @returns {string} */ function getStartAndEndDate(days) { var now = new Date(); var start = now.getFullYear() + "/" + (now.getMonth() + 1) + "/" + now.getDate(); var nowAfterDays = now.setDate(now.getDate() - days); nowAfterDays = new Date(nowAfterDays); var end = nowAfterDays.getFullYear() + "/" + (nowAfterDays.getMonth() + 1) + "/" + nowAfterDays.getDate(); return end + "~" + start; }
标签:gety instance time 间隔 int val logs eof 区间
原文地址:http://www.cnblogs.com/miaoying/p/7698366.html