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中iconv函数使用方法
May 24 PHP
php设计模式 Factory(工厂模式)
Jun 26 PHP
解析用PHP读写音频文件信息的详解(支持WMA和MP3)
May 10 PHP
深入PHP nl2br()格式化输出的详解
Jun 05 PHP
php共享内存段示例分享
Jan 20 PHP
yii2整合百度编辑器umeditor及umeditor图片上传问题的解决办法
Apr 20 PHP
php读取torrent种子文件内容的方法(测试可用)
May 03 PHP
php投票系统之增加与删除投票(管理员篇)
Jul 01 PHP
php操纵mysqli数据库的实现方法
Sep 18 PHP
AJAX的使用方法详解
Apr 29 PHP
Laravel如何创建服务器提供者实例代码
Apr 15 PHP
PHP使用gearman进行异步的邮件或短信发送操作详解
Feb 27 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堆栈与列队的学习
2013/06/21 PHP
thinkphp微信开发(消息加密解密)
2015/12/02 PHP
Thinkphp 框架扩展之数据库驱动常用方法小结
2020/04/23 PHP
基于Jquery与WebMethod投票功能实现代码
2011/01/19 Javascript
javascript string字符串优化问题
2011/07/31 Javascript
JS实现清除指定cookies的方法
2014/09/20 Javascript
javascript中局部变量和全局变量的区别详解
2015/02/27 Javascript
jQuery焦点控制图层展示延迟隐藏的方法
2015/03/09 Javascript
jQuery实现提示密码强度的代码
2015/07/15 Javascript
SpringMVC框架下JQuery传递并解析Json格式的数据是如何实现的
2015/12/10 Javascript
Three.js的使用及绘制基础3D图形详解
2017/04/27 Javascript
详解vue嵌套路由-params传递参数
2017/05/23 Javascript
Webpack如何引入bootstrap的方法
2017/06/17 Javascript
Auto.js自动收取自己和好友蚂蚁森林能量脚本
2018/06/28 Javascript
命令行批量截图Node脚本示例代码
2019/01/25 Javascript
JS定义函数的几种常用方法小结
2019/05/23 Javascript
VUE写一个简单的表格实例
2019/08/06 Javascript
element-ui中Table表格省市区合并单元格的方法实现
2019/08/07 Javascript
[04:13]2018国际邀请赛典藏宝瓶Ⅱ饰品一览
2018/07/21 DOTA
用Python编写一个简单的俄罗斯方块游戏的教程
2015/04/03 Python
PyQt5每天必学之切换按钮
2020/08/20 Python
基于Python安装pyecharts所遇的问题及解决方法
2019/08/12 Python
Python流程控制 while循环实现解析
2019/09/02 Python
Python hashlib模块实例使用详解
2019/12/24 Python
python小项目之五子棋游戏
2019/12/26 Python
python-sys.stdout作为默认函数参数的实现
2020/02/21 Python
Python基于Socket实现简易多人聊天室的示例代码
2020/11/29 Python
人力资源部副职的竞聘演讲稿
2014/01/07 职场文书
美德少年事迹材料
2014/01/23 职场文书
优秀少先队员主要事迹材料
2014/05/28 职场文书
市场推广策划方案
2014/06/02 职场文书
银行授权委托书样本
2014/10/13 职场文书
作风建设年活动实施方案
2014/10/24 职场文书
信息技术教研组工作总结
2015/08/13 职场文书
spring项目中切面及AOP的使用方法
2021/06/26 Java/Android
使用Nginx+Tomcat实现负载均衡的全过程
2022/05/30 Servers