August 6th, 2003, 12:48 PM
postgresql time comparison
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.
August 6th, 2003, 01:00 PM
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.
PostgreSQL, it's what's for dinner...
August 6th, 2003, 03:25 PM