How to compare two timestamp values ​​from mysql with php

I have a db with timestamp values ​​in this format: 0000-00-00 00:00:00 When I add this to db, I add a minute to the current time. Now I need to check if the current value added time in db has passed. (x minute).

example add to db:

 $time = strtotime ("+2 minutes"); $mysql_time = gmdate("Ymd H:i:s", $time); 

Then I get this value from db. And you need to compare the current time with this value. I used unix values ​​like this: if(time() <= $unix_time){...} , but now I want to compare the timestamp values. Something like if(timeMysql() <= $mysql_time){..}

+4
source share
1 answer

There is a UNIX_TIMESTAMP function that converts a formatted 0000-00-00 00:00:00 value 0000-00-00 00:00:00 to a linux timestamp time value.

You can use this: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp

0
source

Source: https://habr.com/ru/post/1333374/


All Articles