一个显示当前星期的起止日的脚本
要完成此效果需要两个步骤第一步:把如下代码加入到<head>区域中<SCRIPT LANGUAGE="JavaScript"><!-- Beginfunction 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));}// End --></script>第二步:把如下代码加入到<body>区域中<script>printWeek();</script>查看/参与:讨论/评论 相关文章:Javascript
- 联系我们: QQ:82526114(技术) 411523648(客服) 237057746(财务)
- 电话:+86-762-4372098 邮箱:webmaster@814e.net,support@814e.net
- 粤ICP备05002242号 网监局备案:4403701910502
