lastModified()函数返回当前日期和时间

编程入门 行业动态 更新时间:2024-10-07 04:36:09
本文介绍了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()函数返回当前日期和时间

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

发布评论

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

>www.elefans.com

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