d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Php Date Calculation
Add Reply New Topic New Poll
Member
Posts: 8,635
Joined: Dec 28 2007
Gold: 87.00
Jul 19 2012 04:35am
I have a float value "Work hours" that has work hours left to use ( 8,5 example ) and I would like to reduce time from it. The problem is that my time I want to reduce from the float value are in date format ( H:i:s, 02:36:21 ). What would be best way to handle this calculation?

If I could get my time to seconds I could handle the calculation, but didnt find any solution from google to convert date format to seconds.

Thanks.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jul 19 2012 10:40am
look at strtotime
Member
Posts: 8,635
Joined: Dec 28 2007
Gold: 87.00
Jul 19 2012 12:26pm
Quote (carteblanche @ 19 Jul 2012 18:40)
look at strtotime


Oo thanks, I tried using strtotime before but couldnt get it to work, took deeper look into it now and got what I wanted.

Code
$time = '01:32:15';
$var = strtotime($time);
$hours = date("H", $var);
$mins = date("i", $var);
$secs = date("s", $var);


From here I can get it to work as I wanted to.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll