JavaScript系列:Date对象

<script type="text/javascript">
    var oDate = new Date();
   
var iYear = oDate.getFullYear();
   
var iMonth = oDate.getMonth() + 1; // 月份是从0开始的
    var iDate = oDate.getDate();
   
var iDay = oDate.getDay();
   
switch (iDay) {
       
case 0:
            iDay
= "星期日";
           
break;
       
case 1:
            iDay
= "星期一";
           
break;
       
case 2:
            iDay
= "星期二";
           
break;
       
case 3:
            iDay
= "星期三";
           
break;
       
case 4:
            iDay
= "星期四";
           
break;
       
case 5:
            iDay
= "星期五";
           
break;
       
case 6:
            iDay
= "星期六";
           
break;
    }
    document.write(
"今天是" + iYear + "年" + iMonth + "月" + iDate + "日," + iDay);
</script>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。