note 68311 deleted from function.strftime by derick

From: Date: Sat, 04 Nov 2006 10:39:30 +0000
Subject: note 68311 deleted from function.strftime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-119370@lists.php.net to get a copy of this message
Note Submitter: segfault at nycap dot rr dot com ---- If you need to format a time from a mysql database "time" type field in just plain hours:minutes am/pm format, without leading zeroes on the hours, use this: <?php $mysqltime = '14:35:00'; // Example time field pulled from MySQL. echo ereg_replace('^0([1-9]):', '\\1:', substr_replace(strftime('%r', strtotime($mysqltime)), '', 5, 3)); ?> This outputs: "2:35 PM". There's probably a quicker or easier way to do this, but I didn't see one readily available; so I hope this helps someone.

« previous php.notes (#119370) next »