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 相关文章推荐
Discuz! Passport 通行证整合
Mar 27 PHP
php获取地址栏信息的代码
Oct 08 PHP
php 多个submit提交表单 处理方法
Jul 07 PHP
PHP 最大运行时间 max_execution_time修改方法
Mar 08 PHP
PHP 作用域解析运算符(::)
Jul 27 PHP
windows服务器中检测PHP SSL是否开启以及开启SSL的方法
Apr 25 PHP
微信公众号开发之微信公共平台消息回复类实例
Nov 14 PHP
PHP中的类型约束介绍
May 11 PHP
PHP中file_exists使用中遇到的问题小结
Apr 05 PHP
浅析Yii2缓存的使用
May 10 PHP
php中static 静态变量和普通变量的区别
Dec 01 PHP
PHP+JQUERY操作JSON实例
Mar 23 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
php获取从百度搜索进入网站的关键词的详细代码
2014/01/08 PHP
PHP图片处理之使用imagecopy函数添加图片水印实例
2014/11/19 PHP
php静态文件生成类实例分析
2015/01/03 PHP
ThinkPHP的SAE开发相关注意事项详解
2016/10/09 PHP
PHP使用PDO调用mssql存储过程的方法示例
2017/10/07 PHP
php字符串截取函数mb_substr用法实例分析
2019/06/25 PHP
父子窗体间传递JSON格式的数据的代码
2010/12/25 Javascript
JavaScript判断变量是否为undefined的两种写法区别
2013/12/04 Javascript
轻松掌握JavaScript单例模式
2016/08/25 Javascript
Vue.js组件使用开发实例教程
2016/11/01 Javascript
MUI 上拉刷新/下拉加载功能实例代码
2017/04/13 Javascript
微信小程序商品到详情的实现
2017/06/27 Javascript
浅谈Koa2框架利用CORS完成跨域ajax请求
2018/03/06 Javascript
微信小程序上传图片实例
2018/05/28 Javascript
Redux实现组合计数器的示例代码
2018/07/04 Javascript
基于Python如何使用AIML搭建聊天机器人
2016/01/27 Python
Python迭代和迭代器详解
2016/11/10 Python
Python基于hashlib模块的文件MD5一致性加密验证示例
2018/02/10 Python
python中(str,list,tuple)基础知识汇总
2018/02/20 Python
由Python编写的MySQL管理工具代码实例
2019/04/09 Python
html5使用Canvas绘图的使用方法
2017/11/21 HTML / CSS
德国BA保镖药房韩文网:kr.ba.de
2017/09/04 全球购物
.NET面试问题集
2015/12/08 面试题
求职自荐信怎么写
2014/03/06 职场文书
大课间体育活动方案
2014/03/12 职场文书
签约仪式主持词
2014/03/19 职场文书
幼儿园中班开学寄语
2014/04/03 职场文书
信用社竞聘演讲稿
2014/05/16 职场文书
商业计算机应用专业自荐书
2014/06/09 职场文书
区域销售主管岗位职责
2014/06/15 职场文书
农业项目建议书
2014/08/25 职场文书
2014年学校财务工作总结
2014/12/06 职场文书
世界文化遗产导游词
2015/02/13 职场文书
夏洛特的网观后感
2015/06/15 职场文书
学校教学管理制度
2015/08/06 职场文书
初中数学教学随笔
2015/08/15 职场文书