2011-12-01 75 views

回答

0
var currentDate = new Date() 

的對象的currentdate將有方法:

getMonth() 
getDate() 
getFullYear() 

這應該給你你需要什麼。

編輯:

既然你在文章的標題中提到的時間,它可能是值得一提的是,的currentdate還將有:

getHours() 
getMinutes() 

應該要顯示當前時間爲好。

編輯2:

要扎入頁面加載

<script type="text/javascript"> 
    function buildDate() { 
    var date = new Date(); 
    /*build date string here*/ 
    } 
</script> 

<body onload="buildDate()"> 
Other stuff here... 
</body> 
+0

我想獲取頁面加載的今天報告,但由於我通過服務器端日期,所以當時區更改,然後我無法看到一些記錄。 –

0
var a = "&date=" + (new Date().replace(/\s+/g, "")); 

剛的價值附加到所有鏈接到服務器。在服務器端,您會看到HTTP請求中發現的日期時間。

相關問題