MYSQL date comparison
TO_DAYS (NOW ()-TO_DAYS (date_col) <= 30;
Our date_col must be in the date and time format, not the timestamp,
Mysql> SELECT FROM_UNIXTIME (875996580 );
-> '2017-10-04 22:23:00'
Day (FROM_UNIXTIME (1277709862) returns the number of days since a timestamp passed
Get date: day (FROM_UNIXTIME (add_time ))
Get month: month (FROM_UNIXTIME (add_time ))
Get year: year (FROM_UNIXTIME (add_time ))
After obtaining the timestamp in SQL, format it as day, month, year: day (now (), month (now (), year (now ())
Here, add_time is the field name in the format of linux timestamp.
Mysql> set @ a = unix_timestamp ();
Query OK, 0 rows affected (0.00 sec)
Mysql> select @;
+ ------------ +
| @ A |
+ ------------ +
| 1, 1154942084 |
+ ------------ +
1 row in set (0.00 sec)
Mysql> select from_unixtime (@ );
+ --------------------- +
| From_unixtime (@ a) |
+ --------------------- +
| 17:14:44 |
+ --------------------- +
1 row in set (0.00 sec)