Thursday, May 9, 2024
HomeLanguagesPhpPHP getlastmod() Function

PHP getlastmod() Function

The getlastmod() function is used to get the time of the last modification of the main script of execution. To show the last modification time of the current page, we use the following.

Syntax:

int|false getlastmod()

Parameters: This function does not accept any parameter.

Return Value: It returns the time of the last modification of the current page. The value returned is a Unix timestamp, suitable for the date(). It returns false on error.

 

Example 1:

PHP




<?php
  
$txt = "PHP";
  
echo "I love $txt! \r\n";
echo "This page was last modified on ".
    date("d F Y h:i:s ",getlastmod());
  
?>


Output

I love PHP! 
This page was last modified on 16 June 2021 07:06:06 

Example 2:

PHP




<?php
  
$txt = "Akshit";
$GFG=" neveropen";
  
echo "I am $txt and I love $GFG\r\n";
echo "This page was Last modified on " 
    . date("d F Y h:i:s ",getlastmod());
  
?>


Output

I am Akshit and I love  neveropen
This page was Last modified on 16 June 2021 07:10:46 

Example 3: The following code is modified using the date(“h:ia”) function.

PHP




<?php
    $txt = "This is changed text";
    $GFG =" neveropen";
    echo "$txt of $GFG\r\n";
    echo "<br>";
    echo "This page was Last modified on "
        . date("h:ia ",getlastmod());
?>


Output:

This is changed text of neveropen
This page was Last modified on 01:48pm

Example 3: The following code modified using the date(“H:i:s a”) function.

PHP




<?php
    $txt = "This is new date format";
    $GFG =" neveropen";
    echo "$txt of $GFG\r\n";
    echo "<br>";
    echo "This page was Last modified on "
        . date("H:i:s a",getlastmod());
?>


Output:

This is new date format of neveropen
This page was Last modified on 13:57:47 pm

Reference: https://www.php.net/manual/en/function.getlastmod.php

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

9 COMMENTS

  1. I have been exploring for a bit for any high quality articles or blog posts on this kind of area .
    Exploring in Yahoo I ultimately stumbled upon this site.

    Studying this info So i’m satisfied to express that I’ve an incredibly just right uncanny
    feeling I came upon just what I needed. I so much undoubtedly will
    make certain to don?t disregard this web site and give it a glance on a continuing basis.

    My web blog :: admiral online casino

  2. It’s the best time to make a few plans for the long run and it is time to be happy.

    I have read this publish and if I may just I want to counsel you some attention-grabbing things or suggestions.
    Maybe you could write next articles referring to
    this article. I want to learn more issues approximately it!

    Also visit my web page; online casino complaints

  3. Woah! I’m really loving the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s challenging to get that “perfect balance” between usability and
    appearance. I must say that you’ve done a excellent job with this.
    Also, the blog loads extremely quick for me on Safari.

    Exceptional Blog!

    Feel free to surf to my site … บริการรูดบัตรเครดิต

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments