home *** CD-ROM | disk | FTP | other *** search
/ PC User 2005 May / CD / PCU0505CD.iso / software / full / coffecup / files / html2005.exe / %MAINDIR% / Javascript / HowOldIsThisPage.xml < prev    next >
Encoding:
Text File  |  2005-02-16  |  2.0 KB  |  68 lines

  1. <ccResource>
  2.   <ccTitle>
  3. How Old Is This Page
  4.   </ccTitle>
  5.   <ccCategory>
  6. Fun Stuff
  7.   </ccCategory>
  8.   <ccDescription>
  9. This script will display to your users how long in years, months, days your site has been active.
  10.   </ccDescription>
  11.   <ccInstructions>
  12.  
  13.   </ccInstructions>
  14.   <ccHeadContent>
  15.   
  16.   </ccHeadContent>
  17.   <ccBodyContent>
  18. <SCRIPT LANGUAGE="JavaScript">
  19. function DateEstablished(startmonth, startdate, startyear) {
  20. sdate=startdate;
  21. smonth=startmonth-1;
  22. syear=startyear;
  23. var DaysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  24. today = new Date()
  25. var thisyear = today.getFullYear();
  26. var thismonth = today.getMonth();
  27. var thisdate = today.getDate();
  28. mstart = new Date(syear,(smonth==12?1:smonth+1),1);
  29. days1 = (mstart - new Date(syear,smonth,sdate))/(24*60*60*1000)-1;
  30. mend = new Date(thisyear,thismonth,1);
  31. days2 = (new Date(thisyear,thismonth,thisdate) - mend)/(24*60*60*1000)+1;
  32. dayst = days1 + days2;
  33. if (dayst >= DaysInMonth[smonth])  {
  34. AddOneMonth = 1; 
  35. dayst -= DaysInMonth[smonth]; 
  36. }
  37. else AddOneMonth = 0;
  38. ydiff1 = thisyear-mstart.getFullYear();
  39. mdiff1 = thismonth-mstart.getMonth()+AddOneMonth;
  40. if (mdiff1 >11) { mdiff1=0; ydiff1++; }
  41. if (mdiff1 < 0) { mdiff1 = mdiff1 + 12; ydiff1--; }
  42. temp = (ydiff1==0?"":(ydiff1==1?ydiff1+" year and ":ydiff1 + " years, "));
  43. temp += (mdiff1==0?"0 months, and ":(mdiff1==1?mdiff1+" month, and ":mdiff1+" months, and "));
  44. temp += (dayst==0?"no days":(dayst==1 ? " 1 day." : dayst + " days." ));
  45. return temp;
  46. }
  47. </script>
  48.  
  49. <!-- Copy this into the BODY of your HTML document  -->
  50.  
  51. <SCRIPT LANGUAGE="JavaScript">
  52. document.write("My Website has been in existence for ");
  53. document.write("<font color=red>");
  54. document.write(DateEstablished(06,09,69)); 
  55. // Enter the dates your site was created.  day,month,year
  56. document.write("</font>");
  57. </script>
  58.   </ccBodyContent>
  59.   <ccElementContent>
  60.   
  61.    <ccElementName></ccElementName>
  62.    <ccElementAction></ccElementAction>
  63.    
  64.   </ccElementContent>
  65.   <ccExtraData>
  66.  
  67.   </ccExtraData>
  68. </ccResource>