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 相关文章推荐
Windows Apache2.2.11及Php5.2.9-1的安装与配置方法
Jun 08 PHP
创建数据库php代码 用PHP写出自己的BLOG系统
Apr 12 PHP
php 提速工具eAccelerator 配置参数详解
May 16 PHP
使用php+apc实现上传进度条且在IE7下不显示的问题解决方法
Apr 25 PHP
php中AES加密解密的例子小结
Feb 18 PHP
PHP循环输出指定目录下的所有文件和文件夹路径例子(简单实用)
May 10 PHP
php判断访问IP的方法
Jun 19 PHP
yii2使用ajax返回json的实现方法
May 14 PHP
PHP封装的完整分页类示例
Aug 21 PHP
PHP strripos函数用法总结
Feb 11 PHP
ThinkPHP框架整合微信支付之Native 扫码支付模式一图文详解
Apr 09 PHP
PHP实现的文件浏览器功能简单示例
Sep 12 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 curl常见错误:SSL错误、bool(false)
2011/12/28 PHP
Thinkphp模板中截取字符串函数简介
2014/06/17 PHP
PHP实现克鲁斯卡尔算法实例解析
2014/08/22 PHP
php基于GD库画五星红旗的方法
2015/02/24 PHP
阿里云Win2016安装Apache和PHP环境图文教程
2018/03/11 PHP
Laravel 默认邮箱登录改成用户名登录的实现方法
2019/08/12 PHP
按钮JS复制文本框和表格的代码
2011/04/01 Javascript
深入理解JavaScript高级之词法作用域和作用域链
2013/12/10 Javascript
jQuery实现鼠标划过添加和删除class的方法
2015/06/26 Javascript
原生js获取元素样式的简单方法
2016/08/06 Javascript
基于jQuery ligerUI实现分页样式
2016/09/18 Javascript
js图片切换具体实现代码
2016/10/13 Javascript
JavaScript中绑定事件的三种方式及去除绑定
2016/11/05 Javascript
vue.draggable实现表格拖拽排序效果
2018/12/01 Javascript
详解JavaScript栈内存与堆内存
2019/04/04 Javascript
jQuery实现动态加载(按需加载)javascript文件的方法分析
2019/05/31 jQuery
使用Vue.js 和Chart.js制作绚丽多彩的图表
2019/06/15 Javascript
ES6 let和const定义变量与常量的应用实例分析
2019/06/27 Javascript
bootstrap table插件动态加载表头
2019/07/19 Javascript
JS实现轮播图效果
2020/01/11 Javascript
解决vue下载后台传过来的乱码流的问题
2020/12/05 Vue.js
Python判断文件或文件夹是否存在的三种方法
2017/07/27 Python
详解python中TCP协议中的粘包问题
2019/03/22 Python
Python基本数据结构与用法详解【列表、元组、集合、字典】
2019/03/23 Python
Python读写文件基础知识点
2019/06/10 Python
python3排序的实例方法
2020/10/20 Python
详解通过HTML5 Canvas实现图片的平移及旋转变化的方法
2016/03/22 HTML / CSS
澳大利亚在线时尚精品店:Hello Molly
2018/02/26 全球购物
Ibatis如何使用动态表名
2015/07/12 面试题
养殖行业的创业计划书
2014/01/05 职场文书
棉花姑娘教学反思
2014/02/15 职场文书
群众路线教育党课主持词
2014/04/01 职场文书
贫困生助学金感谢信
2015/01/21 职场文书
结婚保证书(三从四德)
2015/02/26 职场文书
CSS实现九宫格布局(自适应)的示例代码
2022/02/12 HTML / CSS
SQL Server中使用表变量和临时表
2022/05/20 SQL Server