Re: Changing MySQL Date Format

From: Date: Thu, 12 Aug 2004 15:54:11 +0000
Subject: Re: Changing MySQL Date Format
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-193550@lists.php.net to get a copy of this message
Stephan Fiedler wrote:
Hi Harlequin, Harlequin wrote:
[...]
I'm just getting a little hacked of having to explode the damn things every time I use them.
You EXPLODE them?? When you want it human readable why not simply preg_replace("/(\d{4})-(\d{2})-(\d{2})/", "$3-$2-$1" [*], $input); it? or preg_replace it to something machine-readable and for the output use strftime? or even simpler: select unixtimestamp(mytime) and strftime later? Stephan [*] if you want the month leading it is $2-$3-$1...
Or just use DATE_FORMAT() in your query... http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#193550) next »