Post by Ross on Sept 16, 2006 13:16:52 GMT -8
Main Footer
To have it in the form days, months, years use:
<script type="text/javascript">
<!--
/* add "forum age" to the info center
101support.proboards43.com - ross */
var startDate = ['28','06','2005']; // Forum start date in the form ['day','month','year']
// no need to edit below
if(pb_action == 'home') {
var td = document.getElementsByTagName('td');
var sta = new Date();
sta.setDate(startDate[0]);
sta.setMonth(startDate[1]-1);
sta.setYear(startDate[2]);
var cur = new Date();
var dif = cur - sta;
var totalMonth = 0;
var totalYear = 0;
var totalDay = Math.floor(dif/(60 * 60 * 24 * 1000)) + 1;
while(totalDay >= 365) {
totalDay -= 365;
totalYear++;
}
var nDay=365/12;
while(totalDay >= nDay) {
totalDay -= nDay;
totalMonth++;
}
totalDay=Math.round(totalDay);
var age = totalDay+' days';
if(totalMonth > 0)
age += ', '+ totalMonth +' months';
if(totalYear > 0)
age += ', '+ totalYear +' year';
age += '.';
for (i=td.length-1; i>0; i--) {
if(td.width == '40%' && td[i-1].width == '60%') {
td.firstChild.innerHTML += '<br />Forum Age: '+age;
break;
}
}
}
//-->
</script>
Or to have it in the form years, months, days use:
<script type="text/javascript">
<!--
/* add "forum age" to the info center
101support.proboards43.com - ross */
var startDate = ['28','06','2005']; // Forum start date in the form ['day','month','year']
// no need to edit below
if(pb_action == 'home') {
var td = document.getElementsByTagName('td');
var sta = new Date();
sta.setDate(startDate[0]);
sta.setMonth(startDate[1]-1);
sta.setYear(startDate[2]);
var cur = new Date();
var dif = cur - sta;
var totalMonth = 0;
var totalYear = 0;
var totalDay = Math.floor(dif/(60 * 60 * 24 * 1000)) + 1;
while(totalDay >= 365) {
totalDay -= 365;
totalYear++;
}
var nDay=365/12;
while(totalDay >= nDay) {
totalDay -= nDay;
totalMonth++;
}
totalDay=Math.round(totalDay);
var age = "";
if(totalYear > 1)
age += totalYear +' years, ';
else if(totalYear > 0)
age += totalYear +' year, ';
if(totalMonth > 0)
age += totalMonth +' months, ';
age += totalDay+' days.';
for (i=td.length-1; i>0; i--) {
if(td.width == '40%' && td[i-1].width == '60%') {
td.firstChild.innerHTML += '<br />Forum Age: '+age;
break;
}
}
}
//-->
</script>
Modified to fix assumed 30 days/month. - Trublu
To have it in the form days, months, years use:
<script type="text/javascript">
<!--
/* add "forum age" to the info center
101support.proboards43.com - ross */
var startDate = ['28','06','2005']; // Forum start date in the form ['day','month','year']
// no need to edit below
if(pb_action == 'home') {
var td = document.getElementsByTagName('td');
var sta = new Date();
sta.setDate(startDate[0]);
sta.setMonth(startDate[1]-1);
sta.setYear(startDate[2]);
var cur = new Date();
var dif = cur - sta;
var totalMonth = 0;
var totalYear = 0;
var totalDay = Math.floor(dif/(60 * 60 * 24 * 1000)) + 1;
while(totalDay >= 365) {
totalDay -= 365;
totalYear++;
}
var nDay=365/12;
while(totalDay >= nDay) {
totalDay -= nDay;
totalMonth++;
}
totalDay=Math.round(totalDay);
var age = totalDay+' days';
if(totalMonth > 0)
age += ', '+ totalMonth +' months';
if(totalYear > 0)
age += ', '+ totalYear +' year';
age += '.';
for (i=td.length-1; i>0; i--) {
if(td.width == '40%' && td[i-1].width == '60%') {
td.firstChild.innerHTML += '<br />Forum Age: '+age;
break;
}
}
}
//-->
</script>
Or to have it in the form years, months, days use:
<script type="text/javascript">
<!--
/* add "forum age" to the info center
101support.proboards43.com - ross */
var startDate = ['28','06','2005']; // Forum start date in the form ['day','month','year']
// no need to edit below
if(pb_action == 'home') {
var td = document.getElementsByTagName('td');
var sta = new Date();
sta.setDate(startDate[0]);
sta.setMonth(startDate[1]-1);
sta.setYear(startDate[2]);
var cur = new Date();
var dif = cur - sta;
var totalMonth = 0;
var totalYear = 0;
var totalDay = Math.floor(dif/(60 * 60 * 24 * 1000)) + 1;
while(totalDay >= 365) {
totalDay -= 365;
totalYear++;
}
var nDay=365/12;
while(totalDay >= nDay) {
totalDay -= nDay;
totalMonth++;
}
totalDay=Math.round(totalDay);
var age = "";
if(totalYear > 1)
age += totalYear +' years, ';
else if(totalYear > 0)
age += totalYear +' year, ';
if(totalMonth > 0)
age += totalMonth +' months, ';
age += totalDay+' days.';
for (i=td.length-1; i>0; i--) {
if(td.width == '40%' && td[i-1].width == '60%') {
td.firstChild.innerHTML += '<br />Forum Age: '+age;
break;
}
}
}
//-->
</script>
Modified to fix assumed 30 days/month. - Trublu