Re: PHP & PostgreSQL

From: Date: Mon, 30 Dec 2002 14:27:40 +0000
Subject: Re: PHP & PostgreSQL
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-129660@lists.php.net to get a copy of this message
On Mon, 30 Dec 2002 07:57:04 -0600, you wrote: >> >o Pg doesn't have DATE_FORMAT() >> to_char() accomplishes the same thing, for example: >> select to_char(lastlogin, 'FMMM-DD-YYYY FMHH:MI AM') as lastloginf >> from users; > >Unless I missed something, that function doesn't work with unix timestamps. >Is there anythin internal to PG that allows you to convert to and from unix >timestamps? To convert TO a unix timestamp: select date_part('epoch', lastlogin) as lastloginf; or select extract(epoch from lastlogin) as lastloginf; To convert FROM a unix timestamp: select to_char(timestamp 'epoch' + unix_timestamp, 'FMMM-DD-YYYY FMHH:MI AM'); >That's how I did it and it was, indeed, a pain in the butt... But there was >some good that came out of it. When I created the MySQL tables, I didn't >have foreign keys (wasn't using InnoDB), constraints or anything like that >so in recreating the tables, I was able to implement those things to make >life easier down the road when reworking the code and the logic. And there is the major benefit of using Postgres...not to mention sub-selects, views, unions, etc. Once you get used to these things it's very hard to give them up.

« previous php.general (#129660) next »