Top

duration()


PHP Code
+ 0 likes
Please Register to submit score.
Average Score  5.3
Scores Submitted  4
Date Added  Sep 14, 2006
Last Updated  Oct 21, 2007
Tags  duration 
  Bookmark and Share

Introduction

output:
36 years 8 months 3 weeks 2 days 24 minutes 32 seconds
36 years 8 months 3 weeks 2 days
36 years 8 months

Grab the Code

Comments

  (3)  RSS
Hawkee
Comments: 566
 
PHP Snippet:  duration()
Posted on Sep 15, 2006 11:13 pm
What could this be used for? Your description needs a bit more information. Thank you.
krimson
Comments: 47
 
PHP Snippet:  duration()
Posted on Sep 17, 2006 1:39 am
Basically this will transform seconds in human readable durations. The first parameter of the function represents the number of seconds to transform, while the second represents how detailed will the transformation be (in his examples, duration 6 returns years, months, weeks, days, minutes and seconds, while duration 4 returns only years, months, weeks and days).

the biggest value $max_periods should have is 7 (years, months, weeks, days, hours, minutes and seconds), but in some cases, the function will act as with $max_periods = 6 (when one of the time values is null).

I would vote this as a very useful snippet. good job
sean
Comments: 108
 
PHP Snippet:  duration()
Posted on Sep 19, 2006 8:37 pm
Thank-you krimson <3

Please Register or Login to start posting comments.
Bottom