help with date retrieval from mysql onto a php page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
parms
Forum Newbie
Posts: 6
Joined: Wed Aug 07, 2002 5:57 am

help with date retrieval from mysql onto a php page

Post 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:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
parms
Forum Newbie
Posts: 6
Joined: Wed Aug 07, 2002 5:57 am

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

Post 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]
parms
Forum Newbie
Posts: 6
Joined: Wed Aug 07, 2002 5:57 am

Post 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.
Post Reply