当前位置: 代码迷 >> ASP >> (紧急)怎么日期转星期
  详细解决方案

(紧急)怎么日期转星期

热度:510   发布时间:2012-03-22 17:43:57.0
(紧急求救!)如何日期转星期
某个日期变量(如2006-12-05)怎么样才能得到是星期几。

------解决方案--------------------
<SCRIPT language=JavaScript>
today = new Date();
var day;
if(today.getDay()==0) day = "星期日 "
if(today.getDay()==1) day = "星期一 "
if(today.getDay()==2) day = "星期二 "
if(today.getDay()==3) day = "星期三 "
if(today.getDay()==4) day = "星期四 "
if(today.getDay()==5) day = "星期五 "
if(today.getDay()==6) day = "星期六 "

var datestr = (today.getYear()) + "- " + (today.getMonth() + 1 ) + "- " + today.getDate() + " " + day;
document.write(datestr);
</SCRIPT>
------解决方案--------------------
WeekDayName(Weekday( "2006-12-05 ",0))
------解决方案--------------------
<%
Dim WeekDay, BG, WeekDayName
WeekDay=DatePart( "w ", "2006-12-5 ") '取得星期几
Select Case WeekDay
Case "1 "
WeekDayName= "星期日 "
Case "2 "
WeekDayName= "星期一 "
Case "3 "
WeekDayName= "星期二 "
Case "4 "
WeekDayName= "星期三 "
Case "5 "
WeekDayName= "星期四 "
Case "6 "
WeekDayName= "星期五 "
Case "7 "
WeekDayName= "星期六 "
END Select
response.write weekdayname
%>
  相关解决方案