Home > Backend Development > PHP Problem > How to convert numbers to time in php

How to convert numbers to time in php

王林
Release: 2023-03-06 19:02:01
Original
1572 people have browsed it

How to convert numbers to time in php: You can use the date() function, such as [$dotime="1357985479";echo date("Y-m-d H:i:s",$dotime);].

How to convert numbers to time in php

Code implementation:

(Recommended tutorial: php video tutorial)

echo $startime=strtotime(date("Y-m-d",time()));//当天0点时间戳
echo "<br/>";
echo $endttime=strtotime(date("Y-m-d",time()).&#39; 23:59:59&#39;);//当天23:59:59的INT类型时间戳
echo "<br/>";
//把数值型转成时间字符型
$dotime="1357985479";
echo date("Y-m-d H:i:s",$dotime);//把数字型时间按格式转换成时间格
echo "<br/>";
//输出当前时间字符串型
echo strtotime(date(&#39;Y-m-d H:i:s&#39;,time()));
echo "<br/>";
//把数值型转成字符串型
echo date(&#39;Y-m-d H:i:s&#39;,&#39;1357985479&#39;);
echo "<br/>";
//把字符串型转成数值型
echo strtotime(&#39;Y-m-d H:i:s&#39;);
//echo "<br/>";
//最近七天
echo strtotime("-7 days")
Copy after login

Running results As follows:

1495065600
1495151999
2013-01-12 10:11:19
1495073470
2013-01-12 10:11:19
1494468670
Copy after login

Related recommendations: php training

The above is the detailed content of How to convert numbers to time in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template