javascript计算本周起止日期

运行效果:

<SCRIPT LANGUAGE="JavaScript">

function formatDate(date) {
var mymonth = date.getMonth()+1;
var myweekday = date.getDate();
return (mymonth + "月" + myweekday+ "日");
}
function printWeek() {
var now = new Date();
var nowDayOfWeek = now.getDay();
var nowDay = now.getDate();
var nowMonth = now.getMonth();
var nowYear = now.getYear();
nowYear += (nowYear < 2000) ? 1900 : 0;
var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
document.write("本周起止:  " + formatDate(weekStartDate) + " 到 " + formatDate(weekEndDate));
}
</script>
<script>
printWeek();
</script>

阅读更多
上一篇php实现记住密码自动登录方法
下一篇PHP将Excel表中的数据导入导出mysql
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭