document.lastModified只显示当前日期?(document.lastModified only displays current date?)

编程入门 行业动态 更新时间:2024-10-25 06:31:19
document.lastModified只显示当前日期?(document.lastModified only displays current date?)

我一直在寻找一种方法来显示页面最后更新的日期。

现在我一直在搜索,一切都指向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年的技术课?

按此处查看脚本

I've been looking for a way to display the date the page last was updated.

Now I've been searching around, and everything points to the document.lastModified function, but however I've tried to fix it, it always shows the current date.

I've tried this example:

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("");

Or a simple one like this:

<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>

Is there any other way to do this? .. Without taking a 3 years tech-class?

Press here to see the scripts live

最满意答案

因为您目前正在修改它。 例如,检查一下。

要根据您的要求进行此项工作,请查看此链接和此链接

检查这将有助于你把它放在底部的页面上:

<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("");

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

check this it will help u Put this on the page at the bottom:

<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("");

更多推荐

本文发布于:2023-04-27 20:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329066.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:只显示   日期   lastModified   document   current

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!