Home > Article > Backend Development > How to convert numerical value to date format in php
php method to convert numerical values into date format: 1. Create a PHP sample file; 2. Use the "date("Y-m-d H:i:s",$dotime);" method to convert the numeric time into the format Just convert it into time format.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.
How to convert numerical values into date format in php?
php value conversion time and time conversion value
The code example is as follows:
echo $startime=strtotime(date("Y-m-d",time()));//当天0点时间戳 echo "<br/>"; echo $endttime=strtotime(date("Y-m-d",time()).' 23:59:59');//当天23:59:59的INT类型时间戳 echo "<br/>"; //把数值型转成时间字符型 $dotime="1357985479"; echo date("Y-m-d H:i:s",$dotime);//把数字型时间按格式转换成时间格 echo "<br/>"; //输出当前时间字符串型 echo strtotime(date('Y-m-d H:i:s',time())); echo "<br/>"; //把数值型转成字符串型 echo date('Y-m-d H:i:s','1357985479'); echo "<br/>"; //把字符串型转成数值型 echo strtotime('Y-m-d H:i:s'); //echo "<br/>"; //最近七天 echo strtotime("-7 days")
The running results are as follows:
1495065600 1495151999 2013-01-12 10:11:19 1495073470 2013-01-12 10:11:19 1494468670
Recommended learning:《PHP video tutorial》
The above is the detailed content of How to convert numerical value to date format in php. For more information, please follow other related articles on the PHP Chinese website!