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中其实也可以用方法链

简单示意一下: 复制代码 代码如下: <?php class test { private $_name = ''; public function setName($name)...

PHP附件下载中文名称乱码的解决方法

本文实例讲述了PHP附件下载中文名称乱码的解决方法。分享给大家供大家参考,具体如下: PHP中,如果要下载的文件名称为中文,则会出现文件标题乱码。 此时就需要对标题进行编码,也就是说先进...

PHP 页面跳转到另一个页面的多种方法方法总结

一、用HTTP头信息 也就是用PHP的HEADER函数。PHP里的HEADER函数的作用就是向浏览器发出由HTTP协议规定的本来应该通过WEB服务器的控制指令,例如声明返回信息的类型("...

PHP字符串处理的10个简单方法

1.确定一个字符串的长度 这是文章中最明显的一个例子,其中的问题是我们如何来确定一个字符串的长度,这里我们不能不提的就是strlen()函数: 复制代码 代码如下: $text = "s...

PHP读取Excel类文件

PHP读取Excel类文件

想要使用PHP读取Excel文件必然要用到PHPExcel开源类库,网上资源应该挺多的。但是每一种的操作必然都是不同的,可原理应该都是大同小异。 这个文件夹里包含的就是PHPExcel类...