diff in minutes not working more than 60


I have the following code:

$date1 = new DateTime($rowFS7['FECHAEVENTO']); // in the format 'm/d/y H:i'

        $today = new DateTime(date('m/d/y H:i'));

        $diff = $date1->diff($today);
        $duracion = $diff->format('%i');

Open in new window

my problem is that when the difference reaches 60, then start to 0 again, i need to subtract the time and the minutes to continue counting when they reach 60, continue counting. Any idea?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You are based on your selection is only interested in the minutes portion of the data.

One option is to convert the data into unix timestamp (seconds since 1/1/1970 UTC)
Then you can perform a simple math subtraction and then devide the number of seconds different by 60 to get the number of minutes.
joyacv2Author Commented:

What is the modification that i need to use in my code?
$today=date('U'); //The local time zone if set will adjust the unix time.
$orig_date=$date1->format('U'); // I think this too will be formatted taking the local timezone if set into consideration.


Where are you getting this data from? database, you might be able to perform this conversion as part of your query. datediff.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.