您的位置 首页 php

PHP如何获取当前页面的最后修改时间

PHP获取当前页面的最后一次修改时间,我们可以通过php中date和getlastmod函数来实现。

PHP如何获取当前页面的最后修改时间

下面我们就通过简单代码示例,给大家介绍PHP获取页面最后修改时间的实现方法。

代码示例如下:

<?php

echo “最后一次修改的时间为:” . date (“Y-m-d H:i:s.”, getlastmod()).”n”;

输出结果如下:

PHP如何获取当前页面的最后修改时间

这里我们获取当前页面的最后修改时间即为:2019-01-25 10:55:13。

主要函数介绍:

date()函数 用于格式化一个本地时间/日期

date ( string $format [, int $timestamp ] ) : string

返回将整数 timestamp 按照给定的格式字串而产生的 字符串 。如果没有给出时间戳则使用本地当前时间。换句话说,timestamp 是可选的,默认值为 time()。

自 PHP 5.1.1 起有几个有用的常量可用作标准的日期/时间格式来指定 format 参数。在 $_SERVER[‘REQUEST_TIME’] 中保存了发起该请求时刻的时间戳。

注:有效的时间戳典型范围是格林威治时间 1901 年 12 月 13 日 20:45:54 到 2038 年 1 月 19 日 03:14:07。(此范围符合 32 位有符号整数的最小值和最大值)。不过在 PHP 5.1 之前此范围在某些系统(如 Windows)中限制为从 1970 年 1 月 1 日到 2038 年 1 月 19 日。

getlastmod()函数 用于获取页面最后修改的时间。

getlastmod ( void ) : int

获取执行的主脚本的最后修改时间。

返回值,返回当前页面最后修改的时间。这个值是一个 Unix 时间戳 ,可以传入 date() 。 错误时返回 FALSE。

本篇文章就是关于PHP获取当前页面的最后修改时间的方法介绍,非常简单易懂,希望对需要的朋友有所帮助!

以上就是PHP如何获取当前页面的最后修改时间的详细内容,更多请关注其它相关文章!

更多技巧请《转发 + 关注》哦!

文章来源:智云一二三科技

文章标题:PHP如何获取当前页面的最后修改时间

文章地址:https://www.zhihuclub.com/79597.shtml

关于作者: 智云科技

热门文章

评论已关闭

14条评论

  1. Hello! I understand this is sort of off-topic however I had to ask.

    Does operating a well-established blog such as yours take a massive amount work?
    I’m brand new to blogging however I do write
    in my diary everyday. I’d like to start a blog so I can easily share my experience and views online.
    Please let me know if you have any suggestions or tips for new aspiring
    blog owners. Appreciate it!

    Also visit my web site

  2. Hello there I am so delighted I found your weblog,
    I really found you by error, while I was looking
    on Aol for something else, Nonetheless I am here now and
    would just like to say cheers for a remarkable post and a
    all round exciting blog (I also love the theme/design), I
    don’t have time to browse it all at the minute but I have bookmarked
    it and also added your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep
    up the superb work.

  3. I was wondering if you ever thought of changing the page layout of your website?

    Its very well written; I love what youve got to say. But maybe you could a little more in the
    way of content so people could connect with it better.
    Youve got an awful lot of text for only having 1 or 2 pictures.

    Maybe you could space it out better?

  4. This web site certainly has all of the information and facts I needed concerning this subject and didn’t know who to ask.

  5. What’s up, I check your new stuff daily. Your humoristic style is awesome, keep up the good work!

  6. Hi there I am so delighted I found your web site, I really found you by mistake,
    while I was searching on Google for something else, Anyways I am
    here now and would just like to say many thanks for a remarkable post and a
    all round entertaining blog (I also love the theme/design), I don’t have time to go through it all at the minute but I have saved it
    and also included your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up
    the great b.

  7. Some tіmes its a pain inn the ass to гead what website owners wrote Ƅut this sitye іs гeally user friendly!

  8. Tremendous things here. I am very happy to peer your
    post. Thanks so much and I’m looking forward to contact you.
    Will you kindly drop me a mail?

  9. Hi to all, the contents existing at this site are actually remarkable for people experience, well, keep up the good work fellows.

  10. This site was… how do you say it? Relevant!!
    Finally I’ve found something that helped me.

    Thanks a lot!

  11. Thanks for every other fantastic post. The place else
    could anyone get that kind of information in such an ideal manner of writing?

    I’ve a presentation subsequent week, and I am at the search for such info.

网站地图