Page 1 of 1

help with date retrieval from mysql onto a php page

Posted: Thu Aug 15, 2002 7:02 am
by parms
whats the best/easiest way to retrieve a date from mysql onto a php page, but having it displayed in european date display. eg dd-mm-yyyy

Please help. :cry:

Posted: Thu Aug 15, 2002 7:07 am
by twigletmac
When you retrieve the data from the database use MySQL's DATE_FORMAT function:

Code: Select all

SELECT field1, field2, DATE_FORMAT(date_field, '%d-%m-%Y') AS date FROM table
MySQL Date and Time Functions

Mac

thanks, it is a slightly more complex scenario. Please see

Posted: Thu Aug 15, 2002 7:19 am
by parms
If you look at the query string below you will see that first of all i need to take the max value from that column and then apply the change. Unfortunately the code below does not work.

Any suggestions?

select DATE_FORMAT(MAX(real_date), '%d-%m-%Y') as homeLast from bulletins

Thanks[/b]

Posted: Thu Aug 15, 2002 8:59 am
by parms
Hi mate

Just to say thanks. It did actually work. It was a syntax error on my side that gave a error.

Both lots of code now work.