I am having :
hours1 : 403440
and date2 as :
2016/01/10
I need to convert date2 in hours and find the difference between the two which should again be in hours.
I am having :
hours1 : 403440
and date2 as :
2016/01/10
I need to convert date2 in hours and find the difference between the two which should again be in hours.
The second parameter of date
is a unix timestamp which is in seconds so multiple your hours by 3600 (3600 seconds per hour).
$hours1 = 403440 * 3600;
$date1 = date("d-m-Y H:i:s", $hours1);
echo $date1;
Output:
09-01-2016 19:00:00
Per your update your code should be:
$date2 = strtotime('2016/01/10');//get date to seconds from 1970
$hours1 = 403440 * 3600; // convert from hours to seconds
echo ($date2 - $hours1)/3600;//subtract seconds then divide by 3600 to get how many hours difference is
Output:
5