Home  >  Article  >  Backend Development  >  PHP gets the last modification time of the current page

PHP gets the last modification time of the current page

coldplay.xixi
coldplay.xixiOriginal
2020-08-06 11:36:261611browse

PHP method to get the last modified time of the current page: Use the [date()] function to format the local time or date, and use the [getlastmod()] function to get the last modified time of the page. The code is [getlastmod( void ):int].

PHP gets the last modification time of the current page

PHP method to get the last modification time of the current page:

Method function:

<?php
echo "最后一次修改的时间为:" . date ("Y-m-d H:i:s.", getlastmod())."\n";

Main function introduction:

date() Function is used to format a local time/date

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

Returns an integer timestamp generated according to the given format string String. If no timestamp is given, the local current time is used. In other words, timestamp is optional and the default value is time().

Since PHP 5.1.1 there are several useful constants that can be used as standard date/time formats to specify the format parameter. The timestamp of the time when the request was initiated is saved in $_SERVER['REQUEST_TIME'] .

Note: The typical range of valid timestamps is December 13, 1901 20:45:54 GMT to January 19, 2038 03:14:07 GMT. (This range conforms to the minimum and maximum values ​​of 32-bit signed integers). However, prior to PHP 5.1 this range was limited to January 1, 1970 to January 19, 2038 on some systems such as Windows.

getlastmod()The function is used to get the last modified time of the page

getlastmod ( void ) : int

Get the last modified time of the executed main script.

Return value, returns the last modified time of the current page. This value is a Unix timestamp that can be passed into date(). Returns FALSE on error.

Related learning recommendations: php programming (video)

The above is the detailed content of PHP gets the last modification time of the current page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn