我是 cakephp 的新手,我希望执行以下操作:我有一个 dateTime 对象,我想给它加减 30 分钟。以下是我在控制器中的代码:
$time = $this->request->data['Rideoffer']['DepartureTime'];
$date = new DateTime($time['hour'] . ':' . $time['min'] . ' ' . $time['meridian']);
$currentDate = strtotime($date['date']); // this line gives error
$futureDate = $currentDate+(60*30);
$formatDate = date("Y-m-d H:i", $futureDate);
当我调试 $date 我得到以下结果:
object(DateTime) {
date => '2013-03-08 05:54:00'
timezone_type => (int) 3
timezone => 'UTC'
}
我想date
从这个对象中提取。我该怎么做?