87,907
社区成员
发帖
与我相关
我的任务
分享
<%
Dim a
a=CDate("2010-9-6")
response.write Year(a) & "年" & Month(a) & "月,共有" & days(a) & "天<br>"
response.write Year(a) & "年"&Month(a) & "月,共有" & weeks(a) & "个星期<br>"
write_fl_Weekday a
Function days(d)
days=DateDiff("d",a,Dateadd("m",1,d))
End function
Function weeks(d)
ds=days(d)
If ds Mod 7>0 Then
weeks=Int(ds/7)+1
Else
weeks=Int(ds/7)
End if
End Function
Function write_fl_Weekday(a)
f=CDate(Year(a) & "-" & Month(a) & "-1")
l=DateAdd("d",f,days(a)-1)
response.write "本月第一天("& f &")是:" & WeekDayName(Weekday(f)) & "<br>"
response.write "本月最后一天("& l &")是:" & WeekDayName(Weekday(l)) & "<br>"
End Function
%>
<%
Dim a,b
a=CDate("2009-9-6")
b=WeekDayName(Weekday(a))
response.write b
%>
var myDate = new Date();
myDate.getYear(); //current year(2位)
myDate.getFullYear(); //current full year(4位,1970-now)
myDate.getMonth(); //current month(0-11,0-->1月)
myDate.getDate(); //current day(1-31)
myDate.getDay(); //current weekday(0-6,0-->日曜日)
myDate.getTime(); //current time(Milliseconds form 1970.1.1)
myDate.getHours(); //current hour(0-23)
myDate.getMinutes(); //current minute(0-59)
myDate.getSeconds(); //current second(0-59)
myDate.getMilliseconds(); //current Milliseconds(0-999)
myDate.toLocaleDateString(); //get current date
var mytime=myDate.toLocaleTimeString(); //get current time
myDate.toLocaleString( ); //get current date and time
function YearMonth(year, month) {
this.year = year;
this.month = month;
this.isLeapYear = new Date(year,1,29).getDate() < 29 ? false : true;
}
YearMonth.prototype = {
days:[31,28,31,30,31,30,31,31,30,31,30,31
],
//该月有几天
getDaysCount : function() {
return (this.isLeapYear && this.month==2 ) ? 29 : this.days[this.month-1];
},
//该月有几周
getWeeksCount : function() {
var firstday = new Date(this.year, this.month, 1).getDay();
var firstWeekDays = 6-firstday;
var remainDays = this.getDaysCount()-firstWeekDays;
return Math.ceil(remainDays / 7 + 1);
},
//第一天是周几
getFirstDayInfo : function() {
var first = new Date(this.year, this.month, 1);
return this.getWeek(first.getDay());
},
//最后天是周几
getLastDayInfo : function() {
var last = (this.isLeapYear && this.month==2 ) ? 29 : this.days[month-1];
last = new Date(this.year, this.month, last);
return this.getWeek(first.getDay());
},
//判断周几
getWeek : function(index) {
switch(index) {
case 0 : return 'sun'; break;
case 1 : return 'mon'; break;
case 2 : return 'tue'; break;
case 3 : return 'wed'; break;
case 4 : return 'thu'; break;
case 5 : return 'fri'; break;
case 6 : return 'sat'; break;
default: alert('invalid');
}
}
}
window.onload = function() {
var ym = new YearMonth(2009, 9);
var days = ym.getDaysCount();
var weeks = ym.getWeeksCount();
}