Home > php教程 > PHP源码 > php 时间转换日期与日期转换成时间

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

WBOY
Release: 2016-06-08 17:29:43
Original
1135 people have browsed it

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);
}
?>

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