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手册上有这么一段话: “在处理字符变量的算数运算时,PHP 沿袭了 Perl 的习惯,而非 C 的。例如,在 Perl 中 $a = 'Z'; $a++; 将把 $a 变成...

php之curl实现http与https请求的方法

本文实例讲述了php之curl实现http与https请求的方法,分享给大家供大家参考。具体如下: 通常来说,php的curl函数组可以帮助我们把机器伪装成人的行为来抓取网站,下面来分享...

php 远程图片保存到本地的函数类

<?php // // Function: 获取远程图片并把它保存到本地 // // // 确定您有把文件写入本地服务器的权限 // // // 变量说明: // $url 是远程...

php将fileterms函数返回的结果变成可读的形式

复制代码 代码如下: function perms_str($perms){     if (($perms & 0xC000) == 0xC000) {  ...

PHP实现简单ajax Loading加载功能示例

本文实例讲述了PHP实现简单ajax Loading加载功能。分享给大家供大家参考,具体如下: var xmlHttp; function createXmlHttpReq() {...