Kevin Stussman | 1 Apr 2003 04:02
Favicon

BUG : Postgres Date Problem (and fix)

Anyone using postgres might notice that the "last login" date for a user
will be something like this on the user admin page:

Last login: 1969-12-31 16:59:59

This is because php cannot parse the Postgresql date : 

2003-03-27 12:50:53.543302-07

This is the standard date format for postgreql. When PHP runs this
through the date("Y-m-d H:i:s",strtotime($field[5])) function (as is
done in user-list.php), I believe it just chokes.

The fix is to use something like :

SELECT email, name, nickname, created, login_cnt,
date_trunc('second',last_login)

in the SQL....of course, this might not be the best solution for
non-postgres people :-)

Regards,

Kevin

-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
(Continue reading)

Blake Watters | 4 Apr 2003 03:41
Favicon

Re: BUG : Postgres Date Problem (and fix)

Kevin -

Thanks for the note. I've committed the change to CVS to support the 
postgres users.

Blake

At 07:02 PM 3/31/2003 -0700, Kevin Stussman wrote:
>Anyone using postgres might notice that the "last login" date for a user
>will be something like this on the user admin page:
>
>Last login: 1969-12-31 16:59:59
>
>This is because php cannot parse the Postgresql date :
>
>2003-03-27 12:50:53.543302-07
>
>This is the standard date format for postgreql. When PHP runs this
>through the date("Y-m-d H:i:s",strtotime($field[5])) function (as is
>done in user-list.php), I believe it just chokes.
>
>The fix is to use something like :
>
>SELECT email, name, nickname, created, login_cnt,
>date_trunc('second',last_login)
>
>in the SQL....of course, this might not be the best solution for
>non-postgres people :-)
>
>Regards,
(Continue reading)


Gmane