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 Smarty 字符比较代码

eq相等, ne、neq不相等, gt大于, lt小于, gte、ge大于等于, lte、le 小于等于, not非, mod求模。 is [not] div by是否能被某数整除, i...

在JavaScript中调用php程序

复制代码 代码如下:<SCRIPT Language = "JavaScript"> function func() { if(confirm("Are you OK wit...

php部分常见问题总结

目录: 1:为什么我得不到变量 2:调试你的程序 3:如何使用session 4:为什么我向另一网页传送变量时,只得到前半部分,以空格开头的则全部丢失 5:如何截取指定长度汉字而不会出现...

用php或asp创建网页桌面快捷方式的代码

用php或asp创建网页桌面快捷方式的代码

新建一个PHP文档:名字好记就行如:shortcut.php PHP文档中的内容: 代码 复制代码 代码如下: <?php $Shortcut = "[InternetShortc...

Mac系统下安装PHP Xdebug

Mac系统下安装PHP Xdebug

Mac下安装PHP调试工具Xdebug 安装步骤 brew install php70 brew install php70-xdebug php -i | grep...