以下代码保存为htm文件,用ie打开此文件即可
=================
<html>
<body>
<script language="vbscript">
msgbox DateDiff("ww",year(date) & "-1-1",date,1,1)
</script>
</body>
</html>
================
二、输入年,第几周计算,自动计算这周的起始和终止日期
把下面代码复制粘贴在记事本内,另存为:第几周起始日期html,用ie打开即可
==============
<!javascript:>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 40 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
function showDateCount(year,weekNum){
var date=new Date(year,0,(7weekNum));
var FD=new Date(dategetYear(),(dategetMonth()),(dategetDate()-dategetDay()+1))
var Monday=FDgetYear()+"-"+(FDgetMonth()+1)+"-"+FDgetDate()//一周的第一天
var LD=new Date(dategetYear(),(dategetMonth()),(dategetDate()-dategetDay()+7))
var Sunday=LDgetYear()+"-"+(LDgetMonth()+1)+"-"+LDgetDate() //一周的最后一天
alert(year+"年第"+weekNum+"周是"+Monday+"至"+Sunday)
}
</SCRIPT>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<input type="text" value="2007" size="20" name="year">年<input type="text" name="weekNum"
value="30" size="20">
<input type="button" name="GO" value="Click" onClick="showDateCount
(yearvalue,weekNumvalue)">
</BODY>
</HTML>
========================================
也可以把两个 合在一起,楼上的答案是一个日历,也可以加在一起使用。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 10 Transitional//EN" ">
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)