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

yipeiwu_com5年前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实现webservice实例

本文实例讲述了php实现webservice的方法。分享给大家供大家参考。具体实现方法如下: 首先大家要简单了解何谓webservice,接下来就做两个非常简单的例子,webservic...

PHP得到mssql的存储过程的输出参数功能实现

在开发过程中可能会遇到无法取得MSSQL存储过程的输出参数,很多朋友都不知道该怎么办,本文将详细介绍PHP得到mssql的存储过程的输出参数功能实现,需要了解的朋友可以参考下复制代码 代...

fleaphp crud操作之find函数的使用方法

find函数的原型 复制代码 代码如下: /** * 返回符合条件的第一条记录及所有关联的数据,查询没有结果返回 false * * @param mixed $conditions *...

PHP实现的策略模式简单示例

本文实例讲述了PHP实现的策略模式。分享给大家供大家参考,具体如下: 比如说购物车系统,在给商品计算总价的时候,普通会员肯定是商品单价乘以数量,但是对中级会员提供8者折扣,对高级会员提供...

php实现用手机关闭计算机(电脑)的方法

本文实例讲述了php实现用手机关闭计算机(电脑)的方法。分享给大家供大家参考。具体分析如下: 适合有手机和电脑,用wifi的php web开发。方便关闭你的电脑(尤其在你想睡觉时 ),适...