im using postgresql
php date format
Moderator: General Moderators
-
php_postgresql
- Forum Newbie
- Posts: 13
- Joined: Sat Apr 19, 2008 9:37 am
php date format
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
im using postgresql
Re: php date format
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
Try this. Just change $date to the date from database.
Also, read the date function
Code: Select all
$date = '0000-00-00 00:00:00'; // date from database
$format_date = date('M j Y', strtotime($date));
-
php_postgresql
- Forum Newbie
- Posts: 13
- Joined: Sat Apr 19, 2008 9:37 am
Re: php date format
thanks lafever! 