I got working times type is second.How can I convert 6010 second to 0 day ,0 hour ,10 min ,10 second in php?
Asked
Active
Viewed 2,867 times
0
user2439722
- 39
- 1
- 8
2 Answers
1
You will want an integer division technique.
days = seconds / ( 24 * 60 * 60 )
seconds -= ( days * ( 24 * 60 * 60 ) )
hours = seconds / ( 60 * 60 )
seconds -= ( hours * ( 60 * 60 ) )
minutes = seconds / 60
seconds -= ( minutes * 60 )
Implementing this in PHP should be trivial.
PP.
- 10,574
- 7
- 44
- 58
1
Try this.
$hours = floor($seconds / 3600);
$mins = floor(($seconds - ($hours*3600)) / 60);
Amar Banerjee
- 4,942
- 5
- 30
- 51
-
1why not include link where you got it from? http://stackoverflow.com/questions/3856293/how-to-convert-seconds-to-time-format – Kyslik Jun 12 '13 at 14:03