0
我有一個JavaScript代碼來獲得新的時間。但是當我重新加載頁面的時間不會改變,而是它說1/10/2014 10:57
,我如何添加一個函數的時間和日期來檢測和更改我有javascript來獲取新的時間和日期
下面是我試過的代碼,但它不工作。
<script type="text/javascript">
(function() {
// using current UTC time from server as ref, display local time in div id="now"
var now = new Date();
now.setTime(1389322677492);
var nowstr = ""
+ (now.getMonth() + 1) + "/"
+ now.getDate() + "/"
+ ((now.getYear() < 1000) ? now.getYear() + 1900 : now.getYear()) + " "
+ now.getHours() + ":"
+ ((now.getMinutes() < 10) ? '0' + now.getMinutes() : now.getMinutes());
var el = document.getElementById("now");
el.appendChild(document.createTextNode(nowstr));
})();
</script>
感謝您的幫助。
哦好吧非常感謝 – Wilson