Re: formating numbers & date

From: Date: Thu, 05 Dec 2002 00:37:06 +0000
Subject: Re: formating numbers & date
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-127071@lists.php.net to get a copy of this message
At 04:58 PM 12/4/02 -0700, Jeff Bluemel wrote:
I'm displaying a date that I get from a informix database query - the date format is as follows; 2002-12-04 23:21:49 I want it to display as 12/4/2002 11:21:49 PM
$Hour = substr( $Date, 11, 2 ); if( $Hour ) > 12 { $Hour = $Hour - 12; $AMPM = 'PM'; } else { $AMPM = 'AM'; } echo substr( $Date, 5, 2 ), '/', substr( $Date, 8, 2 ), '/',
     substr( $Date, 0, 4 ), ' ', $Hour, substr( $Date, 13, 6 ), $AMPM;
You may need to adjust the numbers in the substrs... Rick

« previous php.general (#127071) next »