Reputation: 301
I have an external variable coming in a file in the following format:
<?php $var = JHtml::_('date', $item->event_date, this->config->event_date_format, null) ; ?>
which outputs something like this:
09-05-2015 6:00 am
How can I remove the date part and keep only the hours?
Upvotes: 0
Views: 743
Reputation: 22532
Use strtotime and date() for this
$date = '09-05-2015 6:00 am';
echo $time=date("g", strtotime($date));
OUTPUT
6
Upvotes: 1
Reputation: 16
This should do the trick. strtotime() can transform this date into a php-readable date. You can choose which items you want to show (hour, seconds, day, etc). http://php.net/manual/en/function.date.php#format
date('H:s', strtotime($var));
Upvotes: 0