当前位置:首页 > PHP教程 > php日期 > 列表

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

发布:smiling 来源: PHP粉丝网  添加日期:2021-05-17 10:44:35 浏览: 评论:0 

这篇文章主要介绍了PHP使用gmdate实现将一个UNIX 时间格式化成GMT文本的方法,实例分析了php中gmdate函数的功能及使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了PHP使用gmdate实现将一个UNIX 时间格式化成GMT文本的方法。分享给大家供大家参考。具体分析如下:

语法如下:

string gmdate (string $Format)

string gmdate (string $Format, int $Time)

演示代码

  1. <?php 
  2. echo "When this page was loaded,\n"; 
  3. echo 'It was then ', gmdate ('r'), "\n"; 
  4. echo 'The currend gmdate was ', gmdate ('F j, Y'), "\n"; 
  5. echo 'The currend gmdate was ', gmdate ('M j, Y'), "\n"; 
  6. echo 'The currend gmdate was ', gmdate ('m/d/y'), "\n"; 
  7. echo 'The currend gmdate was the ', gmdate ('jS \o\f M, Y'), "\n"; 
  8. echo 'The currend time was ', gmdate ('g:i:s A T'), "\n"; 
  9. echo 'The currend time was ', gmdate ('H:i:s O'), "\n"; 
  10. echo gmdate ('Y'); 
  11. gmdate ('L')?(print ' is'):(print ' is not'); 
  12. echo " a leap year\n"; 
  13. echo time ('U'), " seconds had elapsed since January 1, 1970.\n"; 
  14. ?> 

输出结果如下:

  1. When this page was loaded, 
  2. It was then Sun, 27 Dec 2009 13:08:53 +0000 
  3. The currend gmdate was December 27, 2009 
  4. The currend gmdate was Dec 27, 2009 
  5. The currend gmdate was 12/27/09 
  6. The currend gmdate was the 27th of Dec, 2009 
  7. The currend time was 1:08:53 PM GMT 
  8. The currend time was 13:08:53 +0000 
  9. 2009 is not a leap year 
  10. 1261919333 seconds had elapsed since January 1, 1970. 

希望本文所述对大家的php程序设计有所帮助。

Tags: gmdate UNIX GMT

分享到: