Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2000071

RE: [PHP] how to reformat date info retrieved from mysql in php From: Mike Bosschaert (mbosschaert <email protected>)
Date: 07/07/00

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 <email protected>> on 07-07-2000 12:12:23

To: php-general <email protected>
cc: duh <email protected> (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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>