search
HomeDaily ProgrammingPHP KnowledgeHow to get the last modification time of the current page in PHP

PHP gets the last modification time of the current page. We can achieve this through the date and getlastmod functions in PHP.

How to get the last modification time of the current page 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:

How to get the last modification time of the current page in PHP

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Atom editor mac version download

Atom editor mac version download

The most popular open source editor