2017-06-13 104 views
0

我一直在尋找一種方法來顯示上次更新頁面的日期。document.lastModified只顯示當前日期?

現在我一直在四處搜尋,一切都指向document.lastModified函數,但是我試圖修復它,它總是顯示當前日期。

我已經試過了這個例子:

function lastModified() { 
var modiDate = new Date(document.lastModified); 
var showAs = modiDate.getDate() + "-" + (modiDate.getMonth() + 1) + "-" + modiDate.getFullYear(); 
return showAs 
} 
function GetTime() { 
var modiDate = new Date(); 
var Seconds 

if (modiDate.getSeconds() < 10) { 
Seconds = "0" + modiDate.getSeconds(); } 
else { 
Seconds = modiDate.getSeconds(); } 
var modiDate = new Date(); 
var CurTime = modiDate.getHours() + ":" + modiDate.getMinutes() + ":" + Seconds 
return CurTime } 

document.write("Last updated on "); 
document.write(lastModified() + " @ " + GetTime()); 
document.write(" [D M Y 24 Hour Clock]"); document.write(""); 

或者簡單的一個是這樣的:

<SCRIPT LANGUAGE="JavaScript"> 
var t = new Date(document.lastModified); 
document.write("<I>Last Updated: "+document.lastModified+"</I><BR>"); 
document.write("<I>Last Updated: "+t+"</I><BR>"); 
</SCRIPT> 

是否有任何其他方式做到這一點? ..不用3年的技術課?

Press here to see the scripts live

回答

1

因爲你正在修改它。例如,檢查了這一點。

要根據您的需要這項工作,結賬this linkthis link

檢查這將幫助ü 底部將這個網頁上:

<script type="text/javascript" src="js_lus.js"></script> 
Name the file whatever you want. Example: js_lus.js Make sure src="" 
path is correct for all your pages. 
function lastModified() { 
var modiDate = new Date(document.lastModified); 
var showAs = modiDate.getDate() + "-" + (modiDate.getMonth() + 1) + "-" + 
modiDate.getFullYear(); 
return showAs 
} 

function GetTime() { 
var modiDate = new Date(); 
var Seconds 

if (modiDate.getSeconds() < 10) { 
    Seconds = "0" + modiDate.getSeconds(); 
} else { 
    Seconds = modiDate.getSeconds(); 
} 

var modiDate = new Date(); 
var CurTime = modiDate.getHours() + ":" + modiDate.getMinutes() + ":" + Seconds 
return CurTime 
} 

document.write("Last updated on ") 
document.write(lastModified() + " @ " + GetTime()); 
document.write(" [D M Y 24 Hour Clock]") 
document.write(""); 
+0

這實際上是腳本的一個 – JoBe

+0

我目前正在使用.. – JoBe

+0

你有沒有檢查上面給出的鏈接 –