本文实例讲述了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 of 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 yearn";
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程序设计有所帮助。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!