Home  >  Article  >  php教程  >  php date之间的相互转换

php date之间的相互转换

WBOY
WBOYOriginal
2016-06-06 19:46:381364browse

字符串转成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 可以转换成时间戳,作为转换的中介,将时间在不同的时间格式之间相互转换。

Statement:
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