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 :/
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.
I think you want UNIX_TIMESTAMP()
:
SELECT *
FROM premium
WHERE expired_timestamp >= UNIX_TIMETAMP();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.