使用JavaScript获取服务器时间

不逼逼,直接上代码:(JS原生)

<script language="javascript">
    var now=new Date();
    var x = new Array("星期日", "星期一", "星期二","星期三","星期四", "星期五","星期六");
    var year = now.getFullYear();
    var month = now.getMonth()+1;
    var day = now.getDate();
    var zhou = x[now.getDay()];
    document.write("<span class='theTopDate'>您好,今天是"+year+"年"+month+"月"+day+"日&nbsp;&nbsp;"+zhou+"</span>");
</script>

发表评论

发表评论