Skip to content
Advertisement

How to compare Firebird Database TIMESTAMP with PHP time() value?

My database has a data field of type TIMESTAMP. It’s called “mytime”. I get a number from php’s time() function. e.g:

JavaScript

Then I query the db:

JavaScript

It complains:

JavaScript

I’m guessing you can’t compare a PHP timestamp with a Firebird timestamp. Why not? And how do I get around it?

Advertisement

Answer

There are two options: convert that unix timestamp to a Firebird timestamp before comparison. Or do something like described in this message on the Firebird-Support list:

JavaScript

Or specifically in your query:

JavaScript

Just keep in mind that the times stored in your database may not be stored in UTC, and in that case you need to take the offset against UTC into consideration as well.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement