Re: Time formatting issues
| From: | Chris | Date: | Mon, 16 Jul 2007 07:57:54 +0000 |
| Subject: | Re: Time formatting issues | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258893@lists.php.net to get a copy of this message | ||
Melissa wrote:
I have a DB with a field type DATE (called TideDATE) and a field type TIME (one of which is called highFIRST) How can I format the time fields from displaying 00:00:00 (a 24 hour clock) to HH:MM am/pm format?$time = '13:05:00'; list($hr, $min, $sec) = explode(':', $time); if ($hr > 12) { $new_time = ($hr - 12); $ampm = 'pm'; } elseif ($hr == 12) { $new_time = '12'; $ampm = 'pm'; } else { $new_time = $hr; $ampm = 'am'; } $new_time .= ':' . $min . ':' . $sec . ' ' . $ampm; pretty simple ;) (I'm sure someone will find a way to make this better but that should work :P). -- Postgresql & php tutorials http://www.designmagick.com/