Re: convert postgres date to PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You get that because your input is not a unix timestamp, it's a RFC 3339 formatted date-/timestamp. You first need to convert it (using ie. strtotime, or explode() and feeding it to mktime()) to a unix timestamp before you can feed the unix timestamp to the date() function.

Unix timestamps are integers. When feeding it into date() the STRING (because '2006-11-11 01:02:03' is a STRING) will be converted to an integer (value of 0) and interpreted as being a "valid" unix timestamp (namely, 0). Unix Timestamp = 0 is January 1st, 1970. The start of the UNIX epoch.

- tul

Alain Roger wrote:
Sorry to tell you that but that's why i ask here this question, because i
get everytime 01.01.1970..
RTFM i did !

On 11/11/06, M.Sokolewicz <tularis@xxxxxxx> wrote:

well, I could say RTFM, but I'll help you this time with a few links:
1. date() http://www.php.net/manual/en/function.date.php
2. strtotime() http://www.php.net/manual/en/function.strtotime.php

- tul

P.S. RTFM!

Alain Roger wrote:
> Hi,
>
> in my database PosgreSQL i have stored some date in the following format
:
> YYYY-MM-DD HH:MM:SS
>
> this is a real TimeStamp without time zone field format.
>
> Under PHP i would like to display this field as text with the following
> format "DD.MM.YYYY"
> How can i do that ?
>
> i was thinking to do :
> $date_from_pgsql;
> echo date("d.m.Y",$date_from_pgsql);
>
> but in this case it displays 01.01.1970 :-(
>
> any idea ?
> thanks.
>





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux