php中的时间格式转换函数是strtotime和date。例如将时间戳转换为【Y-m-d H:i:s】,代码为【date("Y-m-d H:i:s",strtotime('2020-08-22'));】。

本教程操作环境:windows10系统、php5.4,本文适用于所有品牌的电脑。 php时间格式转换函数:date()、strtotime()函数,php 原生的时间类也可以转换时间格式。 (学习推荐:php视频教程) 1、Y-m-d转换为时间戳 例:2017-08-22 转化为时间戳 strtotime(‘2017-08-22’); 2、时间戳转换为Y-m-d H:i:s date("Y-m-d H:i:s",strtotime('2017-08-22')); 3、时间Ymd格式转化为Y-m-d date(“Y-m-d”,strtotime("20170822")); 用原生php类也可以直接转换 var_dum(\DateTime::createFromFormat('Ymd','20170822')->format('Y-m-d')); 相关推荐:php培训 以上就是php中的时间格式转换函数是什么的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章! |