javascript输出时间格式:2009年7月7日

用C#就这么简单,看来输出时间用js不太好。
DateTime.Now.ToShortDateString();//输出2009-7-7
DateTime.Now.ToString("yyyy年MM月dd日");
DateTime.Now.ToString(
"D");
javascript居然这么大一堆。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    
<title>javascript输出时间格式:2009年7月7日</title>
    
<script type="text/javascript">    
      
function PageDate(){   
          currentDate 
= new Date()   
          
with(currentDate){   
              day
=getDay()   
              month
=getMonth()+1   
              
this.document.classname="sj"   
              
this.document.write('北京时间   '+getFullYear()+''+month+''+getDate()+'')   
          }   
          
if   (day==1){document.write('   星期一')}   
          
if   (day==2){document.write('   星期二')}   
          
if   (day==3){document.write('   星期三')}   
          
if   (day==4){document.write('   星期四')}   
          
if   (day==5){document.write('   星期五')}   
          
if   (day==6){document.write('   星期六')}   
          
if   (day==0){document.write('   星期日')}   
          
//document.write('<br/>')   
      }   
    
</script>
</head>
<body>
    
<table>
        
<tr>
            
<td>现在时间:</td>
            
<td><script type="text/javascript">PageDate();</script></td>
        
</tr>
    
</table>
</body>
</html>
posted @ 2009-07-08 16:46  大气象  阅读(785)  评论(0编辑  收藏  举报
http://www.tianqiweiqi.com