Link to home
Start Free TrialLog in
Avatar of eduardo12fox
eduardo12foxFlag for Brazil

asked on

Difference in hours between dates

I have two different dates and different times, I would like to know how to do the calculation to get the difference in hours between these two dates example:

$Date1 = "2012-01-01";
$Date2 = "2012-01-02";

$hora1 = "20:00:00";
$hora2 = "21:00:00";

How to calculate the difference between days and hours?
Avatar of Ess Kay
Ess Kay
Flag of United States of America image

use date_add
date_sub — Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object



http://php.net/manual/en/datetime.sub.php
ASKER CERTIFIED SOLUTION
Avatar of Ess Kay
Ess Kay
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eduardo12fox

ASKER

Very, very thank you!!