如何将日期时间转换为时间戳,添加6个小时并将其转换回PHP的最新时间?
问题描述:
如何添加6小时到此字符串?
$ parent =2011-08-04 15:00: 01;
我认为最好的方法是将其转换为时间戳添加21600秒,然后将其转换回日期。
I think the best way is to convert it to timestamp add 21600 seconds and then convert it back to date time.
如何做?
提前感谢
答
你可能正在寻找 http://www.php.net/manual/en/function.strtotime.php 功能
$timestamp = strtotime("2011-08-04 15:00:01");
$timestamp += 6 * 3600;
echo date('Y-m-d H:i:s', $timestamp);