RE: [PHP-DB] displaying a MySQL date in a different format

From: Date: Tue, 07 Jan 2003 11:29:06 +0000
Subject: RE: [PHP-DB] displaying a MySQL date in a different format
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-24612@lists.php.net to get a copy of this message
[snip] > In a receipt to the customer you might want to show them their date of > order and other information using: > > $query="SELECT DATE_FORMAT(o.date, '%m/%d/%Y'), > it.cost > FROM order o, item it > WHERE cust_id = $custId"; > > To display this: > $date=$row["DATE_FORMAT(o.date, '%m/%d/%Y')"]; > > echo $date; As an alternative, you can use a query such as this: $query = "SELECT DATE_FORMAT(o.date, '%m/%d/%Y') as alias, ... and then print the value with $date = $row['alias']; echo $date; instead of using row["DATE_FORMAT(o.date, '%m/%d/%Y')"]; It makes things easier to read in your code, too... ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.db (#24612) next »