how to calculate this format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mit
Forum Commoner
Posts: 32
Joined: Mon Sep 15, 2008 6:37 am

how to calculate this format

Post 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) = ??
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: how to calculate this format

Post by pcoder »

Please make it more clear.
mit
Forum Commoner
Posts: 32
Joined: Mon Sep 15, 2008 6:37 am

Re: how to calculate this format

Post 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;
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: how to calculate this format

Post 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?
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: how to calculate this format

Post by omniuni »

Try explode() ing your numbers and operating on the resulting array.
mit
Forum Commoner
Posts: 32
Joined: Mon Sep 15, 2008 6:37 am

Re: how to calculate this format

Post 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 =??
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: how to calculate this format

Post by pcoder »

Then as omniuni said, use explode() function and do the calculation.
mit
Forum Commoner
Posts: 32
Joined: Mon Sep 15, 2008 6:37 am

Re: how to calculate this format

Post 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...
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: how to calculate this format

Post 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:
Post Reply