Page 1 of 1
php date format
Posted: Tue May 13, 2008 10:40 pm
by php_postgresql
i have a date retrieved from database...... stored in $dateofpurchase........ i want to format it to be viewed like..... Jan. 1, 2007 .....i tried strtotime function and it gives me wrong result of conversion........
im using postgresql

thanks
Re: php date format
Posted: Tue May 13, 2008 11:06 pm
by bhonan
not sure how postgresql formats the date, but for mysql I had to take the date and use the explode() function to split the date in to 3 parts, month, year, and day. (YYYY-MM-DD to YYYY, MM, DD) Then you can use the 3 parts and shuffle them around and arrange it in the way you prefer. I did it in reverse to submit info into my database ($today = date("Y-m-d");)
Re: php date format
Posted: Wed May 14, 2008 12:39 am
by lafever
Try this. Just change $date to the date from database.
Code: Select all
$date = '0000-00-00 00:00:00'; // date from database
$format_date = date('M j Y', strtotime($date));
Also, read the
date function
Re: php date format
Posted: Thu May 15, 2008 7:43 am
by php_postgresql
thanks lafever!
