从MySQL日期时间检查PHP中的已用时间

How can I check how many seconds past the current time to a time in my MySQL database?

Example: The current time right now is 2018-07-21 10:04:20, and the time in my database is 2018-07-20 21:58:40.

I want to get how many seconds past the datetime in my database to the current date time.

Just turn the date into number using strtotime.

$seconds = abs(strtotime($currentDate) - strtotime($dbDate));

I put abs in case of the result is negative.

strtotime returns the difference in seconds between 01-01-1970 and the date in parameter.

You can use the strtotime() to convert your Date-Time to Unixtime an time() to get actual Timestamp:

    $timestamp = strtotime("2018-07-21 10:04:20"); //replace with your DB-date
    $diff =  time() - $timestamp ;                 //calculate the Difference
    echo $diff;                                    //negative number is in the future