Reputation: 43
I want to Check if the Timestamp of now is greater than my Expired Timestamp:
id | created_timestamp | expired_timestamp
1 | 1542570971 | 1542743771
I have tried:
SELECT * FROM premium WHERE expired_timestamp >= now();
Nothing works :/
Upvotes: 3
Views: 1473
Reputation: 28834
You simply need to use UNIX_TIMESTAMP()
function:
SELECT * FROM premium
WHERE expired_timestamp >= UNIX_TIMESTAMP();
NOW()
function returns current datetime in YYYY-MM-DD HH:MM:SS
format. While Unix_Timestamp()
function will return the current datetime's unix timestamp value (unsigned integer). You need to use the latter in your case.
Upvotes: 4
Reputation: 1269623
I think you want UNIX_TIMESTAMP()
:
SELECT *
FROM premium
WHERE expired_timestamp >= UNIX_TIMETAMP();
Upvotes: 2