I’m using Kohana 3.1 and need to convert a date 2011-04-21 into format like 2011-04-21 21:45:00. 21:45:00 is the current time when the date will be selected using a date picker function. I need to compare the date and time. I tried to format date using date helper as follows
$time = Date::formatted_time($actualDate,'Y-m-d H:i:s');
but this gives error “Call to undefined method Date::formatted_time()”; I tried to do it as –
$format = 'Y-m-d';
$date = DateTime::createFromFormat($format, $_POST['actualDate']);
and it gave error “Call to undefined method DateTime::createfromformat()”.
How can I do this in Kohana or use PHP functions to format the date ?
check what version of php you are running (you can use phpinfo() to do that)
kohana 3.1 requires a fairly recent version of php 5.2.x from memory
you can use the native php date function as a option instead
notice the timestamp and format are reversed compared to the kohana function