Page 1 of 1

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

Posted: Fri Aug 07, 2009 11:20 pm
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.

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

Posted: Fri Aug 07, 2009 11:52 pm
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.

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

Posted: Sat Aug 08, 2009 12:00 am
by azri_bech
Thankz