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调用时间格式的参数详解

1、调用语法使用函式date() 实现获取当前的时间格式,例如: 2、时间格式参数设定上面语法中”Y-m-d H:i:s”,显示的格式为: 年-月-日 小时:分钟:秒这样看来,我们只要获...

深入PHP中的HashTable结构详解

深入PHP中的HashTable结构详解

HashTable是Zend引擎中最重要、使用最广泛的数据结构,它被用来存储几乎所有的东西。1.2.1 数据结构HashTable数据结构定义如下:复制代码 代码如下:typedef s...

elgg 获取文件图标地址的方法

过程如下: 首先,实体保存的时候用这个方法(系统本身的): 比如有一个Activity类,继承自ElggObject,创建了一个它的实例 activity, 复制代码 代码如下: //...

PHP单元测试利器 PHPUNIT深入用法(二)第1/2页

PHP单元测试利器 PHPUNIT深入用法(二)第1/2页

1、markTestSkipped和markTestIncomplete   在phpunit中,有两个有用的方法markTestSkipped和markTestIncomplete。...

php 用sock技术发送邮件的函数

使用sock技术发邮件,无需服务器支持。速度快!!  复制代码 代码如下:function send_mail($to,$subject,$body) &n...