22 Dec 2008, 1:11pm
/dev/random
by

1 comment

DateTime To String in PHP

I can never remember this and it always results in much googling when using PHP. How to convert a SQL datetime value to human-readable format (ok, everyone but developers-readable, I happen to like the default datetime representation):

/**
*   Converts the likes of '2008-12-22 12:57:32' to 'December 22, 2008, 12:57 pm'
*/
echo date(  "F j, Y, g:i a", strtotime( $datetime_value ) );

See this page for more details on formatting.