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

yipeiwu_com6年前PHP代码库

本文实例讲述了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程序设计有所帮助。

相关文章

php异常:Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE eval()'d code error

复制代码 代码如下: 1.调用模板中的判断语句不正确。 2.调用php或SiteEngine的一些函数不正确。 3.一些单引号或双引号引起的问题。...

php自定义函数br2nl实现将html中br换行符转换为文本输入中换行符的方法【与函数nl2br功能相反】

本文实例讲述了php自定义函数br2nl实现将html中br换行符转换为文本输入中换行符的方法。分享给大家供大家参考,具体如下: 下面这几个方法将能够帮你解决这个问题。 PHP版将htm...

PHP中防止直接访问或查看或下载config.php文件的方法

或是,PHP的设计本身就避免直接查看文件内容的情况? 从安全角度考虑,这个系统级的文件应该做什么保护措施? 网友完善的答案 经调研,得出以下常用方法: 1 在程序中定义一个标识变量 复制...

php基于表单密码验证与HTTP验证用法实例

本文实例讲述了php基于表单密码验证与HTTP验证用法。分享给大家供大家参考。具体分析如下: PHP 的 HTTP 认证机制仅在 PHP 以 Apache 模块方式运行时才有效,因此该功...

解析PHP中VC6 X86和VC9 X86的区别及 Non Thread Safe的意思

PHP现在推出5.3.0版本了,不过下载的时候有几个不同版本选择。那就是VC6 X86和VC9 X86。首先我来解答: VC6是什么?VC6就是legacy Visual Studio...