本文实例讲述了PHP使用gmdate实现将一个UNIX 时间格式化成GMT文本的方法。分享给大家供大家参考。具体分析如下:
语法如下:
?
|
1
2
|
string gmdate (string $Format)
string gmdate (string $Format, int $Time)
|
演示代码
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<?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";
?>
|
输出结果如下:
?
|
1
2
3
4
5
6
7
8
9
10
|
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程序设计有所帮助。
相关文章
猜你喜欢
- ASP.NET自助建站系统的域名绑定与解析教程 2025-06-10
- 个人服务器网站搭建:如何选择合适的服务器提供商? 2025-06-10
- ASP.NET自助建站系统中如何实现多语言支持? 2025-06-10
- 64M VPS建站:如何选择最适合的网站建设平台? 2025-06-10
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-05-29 42
-
2025-05-25 23
-
2025-05-25 61
-
2025-05-25 26
-
2025-06-04 54
热门评论

