RE: [PHP] how to reformat date info retrieved from mysql in php

From: Date: Fri, 07 Jul 2000 11:09:53 +0000
Subject: RE: [PHP] how to reformat date info retrieved from mysql in php
Groups: php.general 
Request: Send a blank email to php-general+get-5361@lists.php.net to get a copy of this message
Yep, that works fine in general, but I want to use the date field also for ordering the output from the query. When I do the formating in my query, it first sorts on the day, then on month and so on (i didn't know that mysql takes the format used in the select part and not from the source table for ordering). Another option could be that I add both the formatted field and the unformatte field and order on the latter. But the point is that I pass the fields in the SELECT part of the query by a variable (e g $fields='id, date, name, address'). I use the same $field to determine which fields I want to display on my page. Now if I would add a formatted and unformatted date field, both will also be displayed, which is not what I want. I will try the ereg method: ereg( "([0-9]{4})([0-9]{1,2})([0-9]{1,2})", $date, $regs ) which was suggested by Alan (thanks) Mike duh <duh@crash.nu> on 07-07-2000 12:12:23 To: php-general@lists.php.net cc: duh@samhoud.nl (bcc: Mike Bosschaert/YEU/Yakult WW) Subject: RE: [PHP] how to reformat date info retrieved from mysql in php why don't you just let MySQL reformat the date? SELECT DATE_FORMAT(birthdate,'%d %b %Y') as geboortedatum FROM bla WHERE bla=bla much easier and faster... Jeroen Wesbeek Webprogrammeur &Samhoud NetVenture St. Jacobsstraat 16 3500 AK Utrecht 030-2348110 ---- Disclaimer --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

« previous php.general (#5361) next »