# It's a question of time ...

• 04-09-2006
Mandy_C
It's a question of time ...
Hi guys,

i would like to convert a 4 digit number (eg 0824) into a time so that i can find the length of time between two times.
=> so 0824 and 0927 gives 1 hour and 3 minutes

i have found a function in the time.h library => difftime=(time_t timeB, time_t timeA)
but im unsure as to how to declare the numbers etc.

if anyone has any ideas, or good sites for information, i would be very grateful.

thanks
• 04-09-2006
iiwhitexb0iii
since you don't seem to be using seconds you can create a function to convert both times to minutes then subtract the clock out time from the clock in time to get minutes worked.

ex: 0927 = 567 minutes
0824 = 504 minutes

567 - 504 = 63 minutes

hope that helped,
-michael
• 04-09-2006
Mandy_C
great - thanks, it now works like that :)

but i havent agot a clue how i can display integers with a '0' in front.
i.e. 8 is displayed as 08

does any body have an idea?

thanks
• 04-09-2006
Salem
Code:

`printf("%02d",myInt);`
• 04-09-2006
Mandy_C
Of course !!! i shudda known that!!!
:D
Thanks alot anyway, Salem, saved me once again!!!