Re: date format from a database date field

From: Date: Wed, 23 May 2007 18:34:35 +0000
Subject: Re: date format from a database date field
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-255450@lists.php.net to get a copy of this message
Mike Ryan wrote:
Sorry I am a bit of a newbie with php and hope this has not been aswered a million times, but here it goes I have a date base with a couple of date fields when I pull up and display the fields it show 2007-05-21. the question I have is how to convert the field to 05-21-2007? Currently the command I have is print $row['open'];
Well the easiest thing is to let MySQL do the work use following SELECT SELECT DATE_FORMAT(your_date_field,'%m-%d-%Y') as date_field FROM yourtable That should do the work... -- Johan Holst Nielsen Freelance PHP Developer - http://phpgeek.dk

« previous php.general (#255450) next »