Convert the format date from yyyy-mm-dd to dd-mm-yyy

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
azri_bech
Forum Newbie
Posts: 14
Joined: Fri Aug 07, 2009 11:15 pm

Convert the format date from yyyy-mm-dd to dd-mm-yyy

Post by azri_bech »

i'm new php pprogrammer.
I need to help, how to convert the date format from yyyy-mm-dd to dd-mm-yyy.
I want to show on the query result as format dd-mm-yyy.

This is my output query:
<?php echo $row['date_posted'];?> the result is 2009-07-07

Please help me;
Thank you.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Convert the format date from yyyy-mm-dd to dd-mm-yyy

Post by Christopher »

You can probably do something like:

Code: Select all

echo date('%d-$m-%y', strtotime($row['date_posted']));
You could also use substr() to extract the day, month and year if you always know the input format.
(#10850)
azri_bech
Forum Newbie
Posts: 14
Joined: Fri Aug 07, 2009 11:15 pm

Re: Convert the format date from yyyy-mm-dd to dd-mm-yyy

Post by azri_bech »

Thankz
Post Reply