pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Date calc/comparisions
4+ messages / 2 participants
[nested] [flat]

* Date calc/comparisions
@ 2001-09-05 17:24  Brent R. Matzelle <bmatzelle@yahoo.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Brent R. Matzelle @ 2001-09-05 17:24 UTC (permalink / raw)
  To: pgsql-php

I need to know if the date returned from a TIMESTAMP field is less than 24 hours old.  
However, PHP does not understand how to compare times retrieved from PostgreSQL.  
Have any of you any experience with this type of calculation? 

Thanks and warm regards,

Brent





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Date calc/comparisions
@ 2001-09-06 04:01  Mitch Vincent <mvincent@cablespeed.com>
  parent: Brent R. Matzelle <bmatzelle@yahoo.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Mitch Vincent @ 2001-09-06 04:01 UTC (permalink / raw)
  To: pgsql-php; Brent R. Matzelle <bmatzelle@yahoo.com>

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

----- Original Message -----
From: "Brent R. Matzelle" <bmatzelle@yahoo.com>
To: <pgsql-php@postgresql.org>
Sent: Wednesday, September 05, 2001 1:24 PM
Subject: [PHP] Date calc/comparisions


> I need to know if the date returned from a TIMESTAMP field is less than 24
hours old.
> However, PHP does not understand how to compare times retrieved from
PostgreSQL.
> Have any of you any experience with this type of calculation?
>
> Thanks and warm regards,
>
> Brent
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Date calc/comparisions
@ 2001-09-06 15:14  Brent R. Matzelle <bmatzelle@yahoo.com>
  parent: Mitch Vincent <mvincent@cablespeed.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Brent R. Matzelle @ 2001-09-06 15:14 UTC (permalink / raw)
  To: pgsql-php

--- Mitch Vincent <mvincent@cablespeed.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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Date calc/comparisions
@ 2001-09-06 15:32  Mitch Vincent <mvincent@cablespeed.com>
  parent: Brent R. Matzelle <bmatzelle@yahoo.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Mitch Vincent @ 2001-09-06 15:32 UTC (permalink / raw)
  To: Brent R. Matzelle <bmatzelle@yahoo.com>; pgsql-php

I generally do all my date calculations in PG, it's set of functions for
time spans and such are most excellent..

Good luck!

-Mitch

----- Original Message -----
From: "Brent R. Matzelle" <bmatzelle@yahoo.com>
To: <pgsql-php@postgresql.org>
Sent: Thursday, September 06, 2001 11:14 AM
Subject: Re: [PHP] Date calc/comparisions


> --- Mitch Vincent <mvincent@cablespeed.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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2001-09-06 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-09-05 17:24 Date calc/comparisions Brent R. Matzelle <bmatzelle@yahoo.com>
2001-09-06 04:01 ` Mitch Vincent <mvincent@cablespeed.com>
2001-09-06 15:14   ` Brent R. Matzelle <bmatzelle@yahoo.com>
2001-09-06 15:32     ` Mitch Vincent <mvincent@cablespeed.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox