solved it:
$currentDate = strtotime($date->format('Y-m-d H:i:s'));
but i still dont get it that why cant i use $date['date'], i mean $date like an array.
문제
I am new to cakephp and i wish to do the following: I have a dateTime object and i want to add and subtract 30 minutes to it. Following is my code in controller :
$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);
when i debug $date i get the following result:
object(DateTime) {
date => '2013-03-08 05:54:00'
timezone_type => (int) 3
timezone => 'UTC'
}
i wish to extract date
from this object. How do i do so?
해결책
solved it:
$currentDate = strtotime($date->format('Y-m-d H:i:s'));
but i still dont get it that why cant i use $date['date'], i mean $date like an array.