霜天部落 | 关注LAMP高性能、高并发架构的设计与研究

JS 显示当前日期

<script language="javascript"><!–
var today = new Date();
var week; var date;
if(today.getDay()==0) week="星期日";
if(today.getDay()==1) week="星期一";
if(today.getDay()==2) week="星期二";
if(today.getDay()==3) week="星期三";
if(today.getDay()==4) week="星期四";
if(today.getDay()==5) week="星期五";
if(today.getDay()==6) week="星期六";
date=(today.getYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日"+" ";
document.write(date+week);
// –>
</script>

输出显示为:2006年11月16日 星期四