PHP日期函数date格式化UNIX时间的方法
程序员文章站
2024-02-01 19:49:22
本文实例讲述了php日期函数date格式化unix时间的方法。分享给大家供大家参考。具体分析如下:
日期函数可以根据指定的格式将一个unix时间格式化成想要的文本输出...
本文实例讲述了php日期函数date格式化unix时间的方法。分享给大家供大家参考。具体分析如下:
日期函数可以根据指定的格式将一个unix时间格式化成想要的文本输出
使用到函数语法如下
string date (string $format); string date (string $format, int $time);
下面是演示代码
<?php echo "when this page was loaded,\n"; echo 'it was then ', date ('r'), "\n"; echo 'the currend date was ', date ('f j, y'), "\n"; echo 'the currend date was ', date ('m j, y'), "\n"; echo 'the currend date was ', date ('m/d/y'), "\n"; echo 'the currend date was the ', date ('js \o\f m, y'), "\n"; echo 'the currend time was ', date ('g:i:s a t'), "\n"; echo 'the currend time was ', date ('h:i:s o'), "\n"; echo date ('y'); date ('l')?(print ' is'):(print ' is not'); echo " a leap year\n"; echo time ('u'), " seconds had elapsed since january 1, 1970.\n"; ?>
输出结果如下
it was then sat, 26 dec 2009 07:09:51 +0000 the currend date was december 26, 2009 the currend date was dec 26, 2009 the currend date was 12/26/09 the currend date was the 26th of dec, 2009 the currend time was 7:09:51 am gmt the currend time was 07:09:51 +0000 2009 is not a leap year 1261811391 seconds had elapsed since january 1, 1970.
希望本文所述对大家的php程序设计有所帮助。
推荐阅读
-
PHP日期函数date格式化UNIX时间的方法
-
PHP日期函数date格式化UNIX时间的方法_PHP教程
-
php用date格式化输出指定范畴的时间
-
php date()日期时间函数详解_PHP教程
-
【PHP5.3+】 自带函数date_diff() 计算两日期的间隔
-
php使用date和strtotime函数输出指定日期的方法,datestrtotime
-
PHP日期函数date格式化UNIX时间的方法,dateunix_PHP教程
-
Yii2框架引用bootstrap中日期插件yii2-date-picker的方法_PHP
-
php中time()和date()函数获取时间与本地不一致的问题
-
php时间戳格式化显示友好的时间函数分享,php函数分享_PHP教程