I want to get Only Hours From date by using PHP & Cakephp function.
$date = "2011-07-26 20:05:00";
$hours = ?
I want to get Only Hours From date by using PHP & Cakephp function.
$date = "2011-07-26 20:05:00";
$hours = ?
The date_parse function will return a fulfilled array of a sections of a datetime. use it like this:
$now = date(now()); // "2021-08-30 21:52:21"
$open = date_parse($now)['hour']; // 21
$pattern = '[0-9]{2}:[0-9]{2}';
preg_match('/'.$pattern.'/', '2011-07-26 20:05:00', $matches);
echo $matches[0];