I have variable that holds value 1506947452 and need to extract minutes from that date with formula: started_data - now_date but started_date is in unix timestamp format 10-digit int number...that i received in ajax form and need to put in mysql query i try with this:
SELECT TIMESTAMPDIFF(MINUTE, 1506947452, UNIX_TIMESTAMP());
+-------------------------------------------------------+
| TIMESTAMPDIFF(MINUTE, '1506947452', UNIX_TIMESTAMP()) |
+-------------------------------------------------------+
| NULL |
+-------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
UNIX_TIMESTAMP is seconds seconds since '1970-01-01 00:00:00' in UTC. If you have a variable holding another UNIX_TIMESTAMP, you can get the difference and turn seconds to minutes (and round/truncate the result if needed):
SELECT ROUND((UNIX_TIMESTAMP()-1506947452) / 60, 0)