user3594109
user3594109

Reputation: 1

How to get time from database?

I am working on a very old app that needs to move to a new server and I have a query that looks like this.

"SELECT JOB_ID FROM Jobs WHERE PostingStatus='A' && ListEnd >= ".time();

not sure hot to replace the .time(); section with something that will work the same in a newer version of SQL.

There is a ListEnd column and its has data that looks like this 1207775971. What the query needs to do is by my understanding is that it gets all Active jobs that are >= to the last ListEnd. But I cant seem to figure it out.

Upvotes: 0

Views: 225

Answers (1)

nl-x
nl-x

Reputation: 11832

".time() is not sql. It is PHP and it returns the timestamp (seconds passed since 1 Januari 1970), which is then added to the query.

The mysql equivalent is unix_timestamp, so you can change the above with unix_timestamp()".

But why would you? Both functions still work in newer versions. And if you change it, the the system time of your db server (if hosted on an other machine) will become leading, in stead of your webserver.

Furthermore, what the query does is get all jobs that have a ListEnd set in the future.

PS. When migrating to the new server, do check if the new server has the same time settings (time zone).

Upvotes: 1

Related Questions