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设计模式之迭代器模式的深入解析

PHP设计模式之迭代器模式的深入解析

迭代器(Iterator)模式,它在一个很常见的过程上提供了一个抽象:位于对象图不明部分的一组对象(或标量)集合上的迭代。迭代有几种不同的具体执行方法:在数组属性,集合对象,数组,甚至一...

针对PHP开发安全问题的相关总结

对于互联网应用的开发,作为开发者必须时刻牢记安全观念,并在开发的代码中体现。PHP脚本语言对安全问题并不太关心,特别是对大多数没有经验的开发者来说。每当你做任何涉及到钱财事务等交易问题时...

PHP 获取目录下的图片并随机显示的代码

当时想做一个随机更换背景图片的功能,用JavaScript写的话,程序流程应该是:建立一个图片数组->随机选择数组里其中一个值->生成样式并写入body标签。 可是用JS做的...

phpmyadmin导入(import)文件限制的解决办法

到网上搜索了一下前人的解决办法,大多数都说修改php.ini中的upload_max_filesize,但修改了这个以后,还是提示这个问题;但phpmyadmin在提示这个问题的时候,右...

php读取出一个文件夹及其子文件夹下所有文件的方法示例

本文实例讲述了php读取出一个文件夹及其子文件夹下所有文件的方法。分享给大家供大家参考,具体如下: 今天的需求要在一个文件夹中读取出这个文件夹下所有的文件,当然也包括这个文件夹下面所有的...