This may sound very unlikely to the other question.
I have two hour range.
$start = 18:00;
$end = 2:00;
the result 8 hours.
sample two.
$start = 17:30;
$end = 2:00;
result 7.5 Hours.
How can I get this on PHP code.
This may sound very unlikely to the other question.
I have two hour range.
$start = 18:00;
$end = 2:00;
the result 8 hours.
sample two.
$start = 17:30;
$end = 2:00;
result 7.5 Hours.
How can I get this on PHP code.
Object oriented style:
<?php
$datetime1 = new DateTime('2015-04-13 18:00');
$datetime2 = new DateTime('2015-04-14 02:00');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%H:%I hours');
?>
Procedural Style:
<?php
$datetime1 = date_create('2015-04-13 17:30');
$datetime2 = date_create('2015-04-14 02:00');
$interval = date_diff($datetime1, $datetime2);
echo $interval->format('%H:%I hours');
?>
You can read more at:
http://php.net/manual/en/datetime.diff.php