R – Codeigniter: return datetime from db formatted

codeigniterdatetimeformatformatting

I'd like to format a datetime entry stored in a SQL db in a friendly format.

I'm just returning a simple query as a row(date)…

Is there a quick/easy way to do this?

I can post examples, if need be.

Right now the query is in a foreach loop:

<?php print $row['exp_date']?>

Best Answer

You can always use the php date function

Day of the week:

echo date("l", strtotime($row['exp_date'])); // monday

More complex sample:

echo date("l jS \of F Y h:i:s A", strtotime($row['exp_date'])); // Monday 8th of August 2005 03:12:46 PM