Handling Joomla! dates

For the longest time, I’ve had troubles parsing the Joomla! date. It is normally found in this format: “Y-m-d H:i:s” which translates to: year-month-day hour:minute:second  or  2009-01-29 22:05:15
Many times before I have parsed this date to change to a format that is more user friendly, but it had never been a one liner.

Previously I tried these two methods:

$date = date_parse($row->created);
$date = mktime($date['hour'], $date['minute'], $date['second'], $date['month'], $date['day'], $date['year']);
echo date("M d, 'y", $date);

or

$date = new JDate($row->created);
echo date("M d, 'y", $date->toUnix()); //toFormat only works half of the time.

Today I decided to try something new because those two options are ridiculous and unnecessary. I came up with this:

echo date("M d, 'y", strtotime($row->created));

Nice and short 🙂

Hope you find this useful.

STAY UP TO DATE

Sign up today to stay informed with industry news & trends