-
Issue in getting the time difference between two variables
I have two textboxes that inputted time, and I want to get the difference between two time.
for example:
$IN = 13:35;
$OUT = 17:35;
$OTHours = ($OUT - $IN);
$OTHours = 4.00;
and it is correct, but I have a scenario like this:
$IN = 21:35;
$OUT = 05:35;
$OTHours = -16.00;
it should be 8.00.
Any help is highly appreciated.
Thank you..
-
Hi newphpbees,
First convert the time as strtotime(your $IN time) and also strtotime(your $OUT time)
For Exampl :
print("<?php
$to_time=strtotime("2008-12-13 10:42:00");
$from_time=strtotime("2008-12-13 10:21:00");
echo round(abs($to_time - $from_time) / 60,2)." minute";
?>");
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules