[Solved] subtract from hour not in time format in php

Use explode() to separate the hour / minute pieces, then do the math yourself: list( $hour, $min) = explode( ‘:’, “192:40”); list( $hour_sub, $min_sub) = explode( ‘:’, “02:30”); $result = ($hour – $hour_sub) . ‘:’ . ($min – $min_sub); echo $result; This will print: 190:10 If the time were to wrap around, ($min – $min_sub) … Read more

[Solved] subtraction not working in java program (missing something)

Its very simple you are not calculating applesToOrder and orangesToOrder again after user input so they are taking there previous values of 0, just put these lines just above your last JOptionPane statement and see the magic. applesToOrder = applesTheyNeed – applesTheyHave; orangesToOrder = orangesTheyNeed – orangesTheyHave; 1 solved subtraction not working in java program … Read more

[Solved] Time Subtract in PHP

Check it out: if use $date2 as 24:00 $date1 = new DateTime(’02:40′); $date2 = new DateTime(’24:00′); $finaldate = $date2->diff($date1); echo $finaldate->format(‘%h:%i’); // 21:20 But if use $date2 as 00:00 $date1 = new DateTime(’02:40′); $date2 = new DateTime(’00:00′); $finaldate = $date2->diff($date1); echo $finaldate->format(‘%h:%i’); //02:40 1 solved Time Subtract in PHP