PHP gets the last modification time of the current page. We can achieve this through the date and getlastmod functions in PHP.
Let's use a simple code example to introduce to you the implementation method of getting the last modification time of the page in PHP.
The code example is as follows:
<?php echo "最后一次修改的时间为:" . date ("Y-m-d H:i:s.", getlastmod())."\n";
The output result is as follows:
Here we get the last modified time of the current page: 2019- 01-25 10:55:13.
Main function introduction:
date() function is used to format a local time/date
date ( string $format [, int $timestamp ] ) : string
returns The integer timestamp is a string generated according to the given format 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 stored 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() function is used to get the last modification time of the page.
getlastmod ( void ) : int
Get the last modification 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.
This article is an introduction to the method of getting the last modification time of the current page in PHP. It is very simple and easy to understand. I hope it will be helpful to friends in need!
The above is the detailed content of How to get the last modification time of the current page in PHP. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.