Count weeks and days between two dates

06/11/2011

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script language="JavaScript">

    function inst(){
                        ayear=2011;
   amonth=08;
   aday = 11;
   
   var currentTime = new Date();
   byear=currentTime.getFullYear();
   bmonth= (currentTime.getMonth()+1);
   bday = currentTime.getUTCDate();
            
            
            //firstdate = new Date(ayear,amonth, aday);
            //seconddate = new Date(byear,bmonth,bday);
            
            firstdate = Date.UTC(ayear,amonth, aday,0,0,0);
            seconddate = Date.UTC(byear,bmonth,bday,0,0,0);

            DAY = 60 * 1000 * 60 * 24;
            daydif = (seconddate-firstdate)/ DAY;
            
            weeks = daydif / 7;

            sparedays = daydif%7;
              
            return "Semanas: " + parseInt(weeks) +" <br/> Dias: "+sparedays;
            document.dateform.yahoo.value = "Semanas: " + parseInt(weeks) +"  Dias:"+sparedays;
            
            //lastdigit=document.snform.sn3.value.charAt(3);
            //document.snform.results.value=instructor[lastdigit];
            //document.snform.address.value=email[lastdigit];
            //document.links[0].href="mailto:"+email[lastdigit];    
            
        
     }

</script>
</head>
<body>
<script type="text/javascript">
document.write(inst());
</script>
</body>
</html>