Using timespan |
[eluser]quindo[/eluser]
I'm using timespan in a test. I use it to display my age using this command: Code: timespan(mktime(5,0,0,3,3,1973),$now); However, today (24-Feb-2008, 14:32) it gives this output: 35 Years, 1 Day, 9 Hours, 32 Minutes Somewhere something went wrong. Anybody any idea what I'm doing wrong?
[eluser]Seppo[/eluser]
The function assumes all years has 365 days and each month as 30 days... so in a long period you will have problems with the leap years
[eluser]mdavis1982[/eluser]
Hi... You might want to check out http://uk.php.net/manual/en/ref.datetime.php which has some examples for calculating the difference between two dates in the comments. It seems like it would fit the bill completely! Thanks... Matt
[eluser]quindo[/eluser]
Thank you for that information. I used the code there to replace the timespan code in the codeigniter date helper: Code: function timespan ($t1=1, $t2 = '', $precision = 6, $abbr = false)
[eluser]mdavis1982[/eluser]
No Problem... I'm glad it helped! Cheers... Matt |
Welcome Guest, Not a member yet? Register Sign In |