PHPはgmdateを使用して、UNIX 1つをGMTテキストにフォーマットする方法を実現します。
この例では、PHPがgmdateを使用して、UNIX時間をGMTテキストにフォーマットする方法を説明している。皆さんの参考にしてください。具体的な分析は以下の通りです。
文法は以下の通りです
文法は以下の通りです
string gmdate (string $Format)
string gmdate (string $Format, int $Time)
デモコード
<?php
echo "When this page was loaded,
";
echo 'It was then ', gmdate ('r'), "
";
echo 'The currend gmdate was ', gmdate ('F j, Y'), "
";
echo 'The currend gmdate was ', gmdate ('M j, Y'), "
";
echo 'The currend gmdate was ', gmdate ('m/d/y'), "
";
echo 'The currend gmdate was the ', gmdate ('jS \o\f M, Y'), "
";
echo 'The currend time was ', gmdate ('g:i:s A T'), "
";
echo 'The currend time was ', gmdate ('H:i:s O'), "
";
echo gmdate ('Y');
gmdate ('L')?(print ' is'):(print ' is not');
echo " a leap year
";
echo time ('U'), " seconds had elapsed since January 1, 1970.
";
?>
出力結果は以下の通りです。
When this page was loaded,
It was then Sun, 27 Dec 2009 13:08:53 +0000
The currend gmdate was December 27, 2009
The currend gmdate was Dec 27, 2009
The currend gmdate was 12/27/09
The currend gmdate was the 27th of Dec, 2009
The currend time was 1:08:53 PM GMT
The currend time was 13:08:53 +0000
2009 is not a leap year
1261919333 seconds had elapsed since January 1, 1970.
本論文で述べたように、皆さんのphpプログラムの設計に役に立ちます。