欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PHP使用gmdate实现将一个UNIX 时间格式化成GMT文本的方法

程序员文章站 2024-02-05 21:44:58
本文实例讲述了php使用gmdate实现将一个unix 时间格式化成gmt文本的方法。分享给大家供大家参考。具体分析如下: 语法如下: string gmd...

本文实例讲述了php使用gmdate实现将一个unix 时间格式化成gmt文本的方法。分享给大家供大家参考。具体分析如下:

语法如下:

string gmdate (string $format)
string gmdate (string $format, int $time)

演示代码

<?php
echo "when this page was loaded,\n";
echo 'it was then ', gmdate ('r'), "\n";
echo 'the currend gmdate was ', gmdate ('f j, y'), "\n";
echo 'the currend gmdate was ', gmdate ('m j, y'), "\n";
echo 'the currend gmdate was ', gmdate ('m/d/y'), "\n";
echo 'the currend gmdate was the ', gmdate ('js \o\f m, y'), "\n";
echo 'the currend time was ', gmdate ('g:i:s a t'), "\n";
echo 'the currend time was ', gmdate ('h:i:s o'), "\n";
echo gmdate ('y');
gmdate ('l')?(print ' is'):(print ' is not');
echo " a leap year\n";
echo time ('u'), " seconds had elapsed since january 1, 1970.\n";
?>

输出结果如下:

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程序设计有所帮助。