date postgres and php

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
soshea
Forum Commoner
Posts: 31
Joined: Tue Nov 12, 2002 11:22 pm
Location: Idaho
Contact:

date postgres and php

Post by soshea »

any suggestions on this would be appreciated:
when selecting a date from a table on a postgres DB the date is returned in this format:
2003-05-06
i would like to change the date when outputted with PHP to:
05/06/2003 (or any other format that i would like)
can you reformat the date with postgres or am i going to have to explode it with php?
select date_format(mm/dd/yyyy,inevents_date) from events
or
explode('-'.$data[inevents_date])
any ideas?????
(examples would be great!!)
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

not tested:
$date = implode("/",array_reverse(explode("-",$date)));
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you can do it in the database though, that would be the best solution.

I did a Google, and found these:
http://www.oreilly.com/news/sqlnut_1200.html
http://forums.devshed.com/archive/21/2002/10/2/44536

Mac
Post Reply