getlastmod() 函數用於獲取執行主腳本的最後修改時間。為了顯示當前頁麵的最後修改時間,我們使用以下內容。
用法:
int|false getlastmod()
參數:此函數不接受任何參數。
返回值:它返回當前頁麵最後一次修改的時間。返回值是一個Unix時間戳,適用於date()。它在錯誤時返回 false。
範例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());
?>
輸出
I love PHP! This page was last modified on 16 June 2021 07:06:06
範例2:
PHP
<?php
$txt = "Akshit";
$GFG=" GeeksforGeeks";
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());
?>
輸出
I am Akshit and I love GeeksforGeeks This page was Last modified on 16 June 2021 07:10:46
範例3:以下代碼是使用 date(“h:ia”) 函數修改的。
PHP
<?php
$txt = "This is changed text";
$GFG =" GeeksforGeeks";
echo "$txt of $GFG\r\n";
echo "<br>";
echo "This page was Last modified on "
. date("h:ia ",getlastmod());
?>
輸出:
This is changed text of GeeksforGeeks This page was Last modified on 01:48pm
範例3:以下代碼使用 date(“H:i:s a”) 函數修改。
PHP
<?php
$txt = "This is new date format";
$GFG =" GeeksforGeeks";
echo "$txt of $GFG\r\n";
echo "<br>";
echo "This page was Last modified on "
. date("H:i:s a",getlastmod());
?>
輸出:
This is new date format of GeeksforGeeks This page was Last modified on 13:57:47 pm
參考: https://www.php.net/manual/en/function.getlastmod.php
相關用法
- PHP imagecreatetruecolor()用法及代碼示例
- PHP fpassthru( )用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP Ds\Sequence last()用法及代碼示例
- PHP Imagick floodFillPaintImage()用法及代碼示例
- PHP geoip_continent_code_by_name()用法及代碼示例
- PHP GmagickPixel setcolor()用法及代碼示例
- PHP opendir()用法及代碼示例
- PHP cal_to_jd()用法及代碼示例
- PHP stream_get_transports()用法及代碼示例
- PHP Ds\Deque pop()用法及代碼示例
- PHP SimpleXMLElement children()用法及代碼示例
- PHP is_numeric()用法及代碼示例
- PHP Imagick adaptiveSharpenImage()用法及代碼示例
- PHP XMLWriter endDtdEntity()用法及代碼示例
- PHP isset()用法及代碼示例
- PHP ctype_print()用法及代碼示例
- PHP Imagick flopImage()用法及代碼示例
注:本文由純淨天空篩選整理自akshitsaxenaa09大神的英文原創作品 PHP getlastmod() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。