1. 程式人生 > >jquery 動態時間顯示

jquery 動態時間顯示

<font class="font_3" color="#ffffff" style="font-size: 24px; " face="黑體"></font>

function getDate() {  
    var today = new Date();  
    var date = today.getFullYear() + "-" + twoDigits(today.getMonth() + 1) + "-" + twoDigits(today.getDate()) + " ";  
    var week = " 星期" + "日一二三四五六 ".charAt(today.getDay());  
    var time = twoDigits(today.getHours()) + ": " + twoDigits(today.getMinutes()) + ": " + twoDigits(today.getSeconds());  
    $(".font_3").html(date +" "+time);  
}  
function twoDigits(val) {  
    if (val < 10) return "0" + val; return val;  
}  
$(function () {  
    setInterval(getDate, 1000);  
});