lastModified()函数返回当前日期和时间 [英] lastModified() function returns current date and time

查看:77
本文介绍了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()函数返回当前日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆