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


Posted in PHP onMarch 19, 2015

本文实例讲述了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 截取字符串专题集合
Aug 19 PHP
php下载excel无法打开的解决方法
Dec 24 PHP
递归删除一个节点以及该节点下的所有节点示例
Mar 19 PHP
本地计算机无法启动Apache故障处理
Aug 08 PHP
php使用类继承解决代码重复的问题
Feb 11 PHP
PHP实现扎金花游戏之大小比赛的方法
Mar 10 PHP
如何使用php等比例缩放图片
Oct 12 PHP
php中get_magic_quotes_gpc()函数说明
Feb 06 PHP
PHP常用排序算法实例小结【基本排序,冒泡排序,快速排序,插入排序】
Feb 07 PHP
php7 安装yar 生成docker镜像
May 09 PHP
PHP实现字符串翻转功能的方法【递归与循环算法】
Nov 03 PHP
Laravel框架学习笔记之批量更新数据功能
May 30 PHP
php查询mysql数据库并将结果保存到数组的方法
Mar 18 #PHP
PHP使用mysql_fetch_object从查询结果中获取对象集的方法
Mar 18 #PHP
PHP使用mysql_fetch_row查询获得数据行列表的方法
Mar 18 #PHP
PHP使用strtotime计算两个给定日期之间天数的方法
Mar 18 #PHP
PHP使用array_fill定义多维数组的方法
Mar 18 #PHP
php访问数组最后一个元素的函数end()用法
Mar 18 #PHP
php实现兼容2038年后Unix时间戳转换函数
Mar 18 #PHP
You might like
星际流派综述
2020/03/04 星际争霸
中东人咖啡哲学
2021/03/03 咖啡文化
谈谈PHP语法(3)
2006/10/09 PHP
PHP 文件上传功能实现代码
2009/06/24 PHP
PHP6连接SQLServer2005的三部曲
2016/04/15 PHP
PHP 获取 ping 时间的实现方法
2017/09/29 PHP
php中上传文件的的解决方案
2018/09/25 PHP
实例介绍PHP中zip_open()函数用法
2019/02/15 PHP
在JavaScript中获取请求的URL参数
2010/12/22 Javascript
jQuery截取指定长度字符串代码
2014/08/21 Javascript
jQuery中map()方法用法实例
2015/01/06 Javascript
JavaScript中关联原型链属性特性
2016/02/13 Javascript
JS简单实现点击复制链接的方法
2016/08/03 Javascript
Bootstrap3多级下拉菜单
2017/02/24 Javascript
浅谈Node.js轻量级Web框架Express4.x使用指南
2017/05/03 Javascript
Nodejs监控事件循环异常示例详解
2019/09/22 NodeJs
关于vue 项目中浏览器跨域的配置问题
2020/11/10 Javascript
python中from module import * 的一个坑
2014/07/20 Python
在Django框架中编写Context处理器的方法
2015/07/20 Python
详解python之多进程和进程池(Processing库)
2017/06/09 Python
JSON文件及Python对JSON文件的读写操作
2018/10/07 Python
Python多线程应用于自动化测试操作示例
2018/12/06 Python
深入浅析Python 中 is 语法带来的误解
2019/05/07 Python
基于python3 pyQt5 QtDesignner实现窗口化猜数字游戏功能
2019/07/15 Python
python xlwt如何设置单元格的自定义背景颜色
2019/09/03 Python
Python使用monkey.patch_all()解决协程阻塞问题
2020/04/15 Python
Python list和str互转的实现示例
2020/11/16 Python
css3 box-shadow阴影(外阴影与外发光)图示讲解
2017/08/11 HTML / CSS
IWOOT美国:新奇的小玩意
2018/04/27 全球购物
一站式跨境收款解决方案:Payoneer(派安盈)
2018/09/06 全球购物
华纳兄弟工作室的官方授权商店:WB Shop
2018/11/30 全球购物
经贸专业毕业生求职信范文
2014/05/01 职场文书
高考学习决心书
2015/02/04 职场文书
淘宝客服专员岗位职责
2015/04/07 职场文书
P站美图推荐——变身女主角特辑
2022/03/20 日漫
Nginx 502 bad gateway错误解决的九种方案及原因
2022/08/14 Servers