inherit
141591
0
Jun 12, 2012 10:13:43 GMT -8
Zarathustra
78
June 2009
zarathustra
|
Post by Zarathustra on Jun 14, 2010 21:24:00 GMT -8
I am currently using this code on my forum. The day we opened is the day I have on the forum age code (June 20th, 2009, or '20','06','2009' in the code). Which would mean the forum is 12 months old in five days, but it's showing as 12 months and 1 day in the code. Obviously this is incorrect. What is causing this? How can it be fixed?
|
|
inherit
134992
0
May 26, 2012 2:38:57 GMT -8
SubDevo
Creator of LSD...
3,861
December 2008
subdevo
|
Post by SubDevo on Jun 14, 2010 21:55:36 GMT -8
You are right. That code assumes 30 days per month. So the averages don't work out exactly right. This modification will get it "closer" to the correct day count.
Find this section:
totalYear++; } while(totalDay >= 30) { totalDay -= 30; totalMonth++; } var age = "";
Replace it with this:
totalYear++; } var nDay=365/12; while(totalDay >= nDay) { totalDay -= nDay; totalMonth++; } totalDay=Math.round(totalDay); var age = "";
|
|
inherit
141591
0
Jun 12, 2012 10:13:43 GMT -8
Zarathustra
78
June 2009
zarathustra
|
Post by Zarathustra on Jun 15, 2010 10:23:24 GMT -8
Thankyou, this is much better!
|
|
inherit
134992
0
May 26, 2012 2:38:57 GMT -8
SubDevo
Creator of LSD...
3,861
December 2008
subdevo
|
Post by SubDevo on Jun 15, 2010 22:18:28 GMT -8
You're welcome!
|
|