#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Michigan, US
    Posts
    9
    Rep Power
    0

    postgresql time comparison


    Hi,

    I want to compare two time_stamps. one of them is 'now', I can get it with php. Another one is the creating time of the file. I can get it from a table. I want to compare them, if the file is created 5 hours before 'now', then delete it. But now I don't know how to do this? Is there any function in postgresql or PHP like "difference = time1 - time2" ? I searched, but didn't find any answer.

    Thank you very much for any help.

    Helen
  2. #2
  3. Me likey breadsticks...
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2003
    Location
    Los Angeles
    Posts
    1,189
    Rep Power
    18
    You have several options, 2 of which are:

    If you want to do it on PG's end look at the date/time/interval operators here

    You can also use PHP with strotime to turn the dates into unix timestamps and compare the timestamps to see if they are 60 sec * 60 min * 5 hours apart.

    HTH,
    -b
    PostgreSQL, it's what's for dinner...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Michigan, US
    Posts
    9
    Rep Power
    0
    Bcyde, Thank you!

IMN logo majestic logo threadwatch logo seochat tools logo