i'm trying to make a script to calculate the diference between two dates, but in minutes, the thing is that i need to remove from mysql database all the entries that has mora than 15 minutes on the database, i'm planing to run the script in background using the cron jobs, but the main problem is that i don't know how to get the minutes from the two dates, i tried using

$mins = date_diff(date("Y-m-d H:i:s"), $rows["hora"]);

but the php told that the first parameter is a string

any help will be very appreciatted

thanks in advanced for all the help.

5 Years
Discussion Span
Last Post by LastMitch


how calculate minute diference between two dates

Try this:

$to_time = strtotime("2012-10-24 12:00:00");
$from_time = strtotime("2012-10-24 11:54:00");
echo round(abs($to_time - $from_time) / 60,2). " minute";

or read and try this:


Edited by LastMitch: grammer

Votes + Comments
To Rectify what some retard did to LastMitch

thanks LastMitch it works perfect, thank you very much!!!



It's great to hear that you solve it! Can you click Mark Question Solve on the bottom left corner so the thread is close and solve so noone can add stuff to it. Thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.