当前位置: 代码迷 >> Web前端 >> 展示当前时间
  详细解决方案

展示当前时间

热度:266   发布时间:2012-07-28 12:25:13.0
显示当前时间
<script language="JavaScript">
today=new Date();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
var timeValue = "" + ((hours >12) ? hours -12 :hours); timeValue += ((minutes < 10) ? ":0" : ":") + minutes+"";
timeValue += (hours >= 12) ? "PM" : "AM";
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write("",today.getFullYear(),"年","",today.getMonth()+1,"月","",today.getDate(),"日",d[today.getDay()+1]," ",timeValue);
</script>

  相关解决方案