Home > php教程 > php手册 > body text

php date之间的相互转换

WBOY
Release: 2016-06-06 19:46:38
Original
1372 people have browsed it

字符串转成date $str =date("Y-m-d H:i:s",strtotime("2011-12-12 14:23:01")); echo $str; date规则之间的转换, 例如"2011-12-12 14:23:01 转换为"2011-12-12 $d = strtotime(date('Y-m-d H:i :s')); echo date('Y-m-d H:i :s'); echo "/br"; echo $d; ech

字符串转成date

$str =date("Y-m-d H:i:s",strtotime("2011-12-12 14:23:01"));
echo $str;

date规则之间的转换,

例如 "2011-12-12 14:23:01 转换为 "2011-12-12

$d = strtotime(date('Y-m-d H:i:s'));
echo date('Y-m-d H:i:s');
echo "";
echo $d;
echo "";
$t = date('Y-m-d',$d);

strtotime 可以转换成时间戳,作为转换的中介,将时间在不同的时间格式之间相互转换。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!