Home  >  Article  >  php教程  >  php 时间转换日期与日期转换成时间

php 时间转换日期与日期转换成时间

WBOY
WBOYOriginal
2016-06-08 17:29:431062browse

php 时间转换日期与日期转换成时间

<script>ec(2);</script>


$d ='2009-07-02 09:09:00';
echo date("Y-m-d",'1246606382');
echo date('Ymd',dateToTime($d));


$temp = dateToTime($d);
echo $temp;
echo date("Y-m-d",$temp);

function dateToTime($d)
{
 $year=((int)substr("$d",0,4));//取得年份

 $month=((int)substr("$d",5,2));//取得月份
 
 $day=((int)substr("$d",8,2));//取得几号
 
 return mktime(0,0,0,$month,$day,$year);
}
?>

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