Javascript 时间计算函数
<span style="font-size:18px;"> <span style="font-size:18px;">function addZore(x) {if (x < 10) {x = "0" + x;};return x;}//2002-12-18格式 function getCurentDate() { var date = new Date(); var month = date.getMonth() + 1; var day = date.getDate(); month = addZore(month); day = addZore(day); var today = date.getFullYear() + "-" + month + "-" + day; return today; } function getMonday(d) { d = new Date(d); var day = d.getDay(), diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday return new Date(d.setDate(diff)); } function getThreeMonthLateDate() { var begin_date = new Date(); begin_date.setMonth(begin_date.getMonth() + 3); var yyyy = begin_date.getFullYear(); var mm = begin_date.getMonth() + 1; var dd = begin_date.getDate(); month = addZore(mm); day = addZore(dd); var end_date = yyyy + "-" + month + "-" + day; return end_date; } function getThreeMonthLateDateBydate(date_input) { var begin_date = new Date(date_input); alert(begin_date); begin_date.setMonth(begin_date.getMonth() + 3); var yyyy = begin_date.getFullYear(); var mm = begin_date.getMonth() + 1; var dd = begin_date.getDate(); month = addZore(mm); day = addZore(dd); var end_date = yyyy + "-" + month + "-" + day; return end_date; } function addDate(days) { var d = new Date(); d.setDate(d.getDate() + days); var day = d.getDate(); var m = d.getMonth() + 1; month = addZore(m); day = addZore(day); return d.getFullYear() + "-" + month + "-" + day; } function addDateByDate(sDate1,days){ var d = new Date(sDate1); d.setDate(d.getDate() + days); var day = d.getDate(); var m = d.getMonth() + 1; month = addZore(m); day = addZore(day); return d.getFullYear() + "-" + month + "-" + day; }</span></span>
时间: 2024-10-13 01:07:37