本文介绍了lastModified()函数返回当前日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是:为什么当我在网页上使用"document.lastModified"时,它返回给我当前日期和时间,而不是该页面上次修改的时间...有任何想法吗?在此先感谢:)
My question is : why when I use "document.lastModified" on my web page, it returns me the current date and time, not the time when this page was last Modified... Any ideas? Thanks in advance :)
实际代码是:
<script type="text/javascript"> document.write("Page was last modified on: " + document.lastModified);</script> 推荐答案因为您当前正在修改它.查看示例.
Because you are modifying it currently. Check this out for example.
要根据您的要求进行此操作,请签出此链接并此链接
To make this work based on your requirement, checkout this link and this link
从外部链接复制:
将此内容放在页面底部:
Put this on the page at the bottom:
<script type="text/javascript" src="js_lus.js"></script>根据需要命名文件.示例:js_lus.js确保所有页面的src ="路径均正确.
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("");更多推荐
lastModified()函数返回当前日期和时间
发布评论