js分时间段显示不同问候的代码

<script language="javascript">
<!--
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+" ");
var myhour=today.getHours()
if (myhour>=6 && myhour<12)
document.write ("上午好!")
else if (myhour>=12 && myhour<14)
document.write ("中午好!")
else if (myhour>=14 && myhour<18)
document.write ("下午好!")
else if (myhour>=18 && myhour<=24)
document.write ("晚上好!")
else if (myhour<6)
document.write ("凌晨好!")
// -->
</script>
posted @ 2010-06-07 21:09  你妹的sb  阅读(857)  评论(0编辑  收藏  举报
百度一下