Re: Date calc/comparisions

From: "Brent R(dot) Matzelle" <bmatzelle(at)yahoo(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: Date calc/comparisions
Date: 2001-09-06 15:14:22
Message-ID: 20010906151422.84441.qmail@web13002.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

--- Mitch Vincent <mvincent(at)cablespeed(dot)com> wrote:
> You could do
>
> SELECT EXTRACT(EPOCH FROM <timestamp>);
>
> -- To get epoch, then use PHP to do the date calculation.. You
> could do the
> calculation in the database too, though..
>
> Check out
>
http://postgresql.crimelabs.net/users-lounge/docs/7.1/user/functions-datetim
> e.html

Thanks for the response. Actually I found a slightly better way
of accomplishing the same thing last night. I can change the
PostgreSQL TIMESTAMP to a PHP viable Unix timestamp by
eliminating the time zone stuff from the end of the string:

$timestamp = "2001-09-05 21:12:45-04" // simulate a PG timestamp

// Eliminates the "-04"
$timestamp = substr($timestamp, 0, -3);

$unix_time = strtotime($timestamp);

// Now I can convert it:
$pretty_time = date("Y M d H:i", $unix_time);

Regards,

Brent

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Mitch Vincent 2001-09-06 15:32:53 Re: Date calc/comparisions
Previous Message Mitch Vincent 2001-09-06 04:01:50 Re: Date calc/comparisions