|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
time conversion
Hi people
If somebody gives you a total number of seconds, for example 1890 seconds, what is the best way to convert this into total number of hours, minutes and seconds? Thanks! |
|
#2
|
|||
|
|||
|
ill just throw up some psuedocode of what i think would be the best way todo this
first off have a form unless its a set time you are converting but in that case why convert it just write the answers, i dont know what you are doing so here lol on the form have a text field called "secinput" or whatever you want then PHP Code:
like i said its just some pseudocode ideas, i dont even know if thats how you do calculations in php im just a noob and i dont know what exactly you want todo but since no one else responded i thought i would. also you will get decimal answers with the method i showed. good luck Last edited by Chrisw84 : November 17th, 2002 at 07:47 PM. |
|
#3
|
|||
|
|||
|
Just make it separate:
$days = floor($secinput / 60 / 60 / 24); $hours = floor(($secinput -$days*60*60*24)/ 60 / 60); ...etc.. echo"$days-$hours-$minutes-$seconds"; Sincerely, Sergey Booyny AlarIT programmer http://www.AlarIT.com |
|
#4
|
|||
|
|||
|
this worked quite well for me, although the way that serg4444 suggests looks better:
PHP Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > time conversion |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|