用javascript
以下代码显示格式:
2008年08月18日 星期一 上午 9点06分03秒 时分秒会走
<script language="JavaScript">
<!--
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var riqi;
if (now.getDay() == 5) riqi = "星期五";
if (now.getDay() == 6) riqi = "星期六";
if (now.getDay() == 0) riqi = "星期日";
if (now.getDay() == 1) riqi = "星期一";
if (now.getDay() == 2) riqi = "星期二";
if (now.getDay() == 3) riqi = "星期三";
if (now.getDay() == 4) riqi = "星期四";
var timeValue = "";
timeValue += year + "年";
timeValue += ((month < 10) ? "0" : "") + month + "月";
timeValue += ((date < 10) ? "0" : "") + date + "日
"+riqi;
document.write(timeValue);
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
document.write("<span id='clock'></span>");
var now,hours,minutes,seconds,timeValue;
function showtime(){
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
timeValue = (hours >= 12) ? " 下午 " : " 上午 ";
timeValue += ((hours > 12) ? hours - 12 : hours) + "点";
timeValue += ((minutes <10)?"0":"") + minutes+"分";
timeValue += ((seconds <10)?"0":"") + seconds+"秒";
clock.innerHTML = timeValue;
setTimeout("showtime()",100);
}
showtime();
//-->
</script>