Page 1 of 1

format date

Posted: Tue Mar 13, 2007 11:08 pm
by johnhelen
Hello all

I have timestamp field in a table

when I print this value (called $time) as:

echo $time;

I have:

2007-03-13 17:05:07.768449+13

Now I want to display this as:

13-03-07 17:05:07

I tried:

echo date('d-m-y H:i:s', strtotime($time));

It shows

01-01-70 11:59:59

What is wrong here

Please help


Many thanks
Regards
sh

Posted: Tue Mar 13, 2007 11:47 pm
by feyd
That's not a known time format to PHP. "2007-03-13 17:05:07" would be known.

Posted: Wed Mar 14, 2007 4:04 am
by mikeq
In your query that retrieves the data, format the date at that point rather than doing it in PHP.

Look up the date_format function on this page Date Functions

Posted: Wed Mar 14, 2007 7:52 am
by feyd
I believe johnhelen is using Postgre

http://www.postgresql.org/docs/8.2/inte ... etime.html should be of interest.

Posted: Thu Mar 15, 2007 11:22 pm
by johnhelen
Thanks all,
I use function to_date in psql
regards