Page 1 of 1

how to calculate this format

Posted: Mon Oct 20, 2008 1:37 am
by mit
Hi;
I need to calculate this time format 00:00:000 (like: 12:34:768) from 0.0 this format , does any one know how to handle this in php?
eg: 54:73:733(time format) - 13.7(any digit between 0.0 to 20.0) = ??

Re: how to calculate this format

Posted: Mon Oct 20, 2008 1:49 am
by pcoder
Please make it more clear.

Re: how to calculate this format

Posted: Mon Oct 20, 2008 1:53 am
by mit
it s a game , and i ve to deduct a digit between 0 to 20 from this time format 00:00:000
means $latestscore = $score-$medal;

$score=99:99:999;
$medal= 18.7 ;

now how to do this calculation ;
$latestscore = $score-$medal;

Re: how to calculate this format

Posted: Mon Oct 20, 2008 2:10 am
by pcoder
Still i am not clear with you.
What does this $score mean?
I mean, you have separated the score into three parts. Like
AA:BB:CCC and how does the medal related to the score?

Re: how to calculate this format

Posted: Mon Oct 20, 2008 2:13 am
by omniuni
Try explode() ing your numbers and operating on the resulting array.

Re: how to calculate this format

Posted: Mon Oct 20, 2008 2:26 am
by mit
the $medal is a digit from 0 to 20 , that is only a point that user collect up to now... can be 19.9 ,5.8 ,2 or any number between 0 to 20 , but the $score is the time format , 00:00:000 min, second and millisecond...
my problem is i dont know how to deduct time format from number ;
eg = 98:88:999 - 8.7 =??

Re: how to calculate this format

Posted: Mon Oct 20, 2008 3:34 am
by pcoder
Then as omniuni said, use explode() function and do the calculation.

Re: how to calculate this format

Posted: Mon Oct 20, 2008 3:58 am
by mit
yes explode is ok but if the case is like 01:24:222-19.8 = then when i want to borrow from 01 then its value is not 1 , is 60...

Re: how to calculate this format

Posted: Mon Oct 20, 2008 7:26 am
by novice4eva
When you say 01:24:222-19.8 does it mean like 01-00:24-19:222-8, i mean that 19.8 is actually time with 19 sec and 8 millisec ??? It must be the case because if 19.8 were millisec then 19 will be millisec and 0.8 will be something micro sec!!! It seems like you know explode, the best thing would be change everything to milliseconds, do the subtraction and make it to the form you desire which seems like MM:SS:(MILLISEC) :mrgreen: