例子:把字符串时间转换为timestamp_PHP教程

WBOY
发布: 2016-07-13 17:12:30
原创
842 人浏览过

$strtime = "2000-02-12 16:20:35";
$array = explode("-",$strtime);
$year = $array[0];
$month = $array[1];
$array = explode(":",$array[2]);
$minute = $array[1];
$second = $array[2];
$array = explode(" ",$array[0]);
$day = $array[0];
$hour = $array[1];
$timestamp = mktime($hour,$minute,$second,$month,$day,$year);
echo "字符串时间:$strtime
";
echo "年:$year
";
echo "月:$month
";
echo "日:$day
";
echo "时:$hour
";
echo "分:$minute
";
echo "秒:$second
";
echo "转换为timestamp:" . $timestamp . "
";
echo "从timestamp转换回来:" . date("Y-m-d H:i:s",$timestamp) . "
";
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/629354.htmlTechArticle$strtime = 2000-02-12 16:20:35; $array = explode(-,$strtime); $year = $array[0]; $month = $array[1]; $array = explode(:,$array[2]); $minute = $array[1]; $second = $array[2]; $array...
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板