meditationatae

Just another WordPress.com site

Countdown to Winter solstice, valide in Eastern Standar Time (javascript)

<html>
<head>
<script language="JavaScript">

function countdown(){
    //Getting dates in Unix Time, and finding the difference between the current time, and expiration date.  Dividing the UTC time by 1000 to get the Unix Time
    expire = parseInt(Date.parse("Dec 21, 2012")/1000); //End Date
    var now = new Date();
    var current = parseInt(now.getTime()/1000);
    var diff_seconds = expire - current;

    diff_seconds  = diff_seconds + 22297 ;

    //Number of years left
    var diff_years = parseInt(diff_seconds/(60*60*24*365))
    diff_seconds -= diff_years * 60 * 60 * 24 * 365;
    document.getElementById("years").innerHTML=diff_years;

    //Number of days left
    var diff_days = parseInt(diff_seconds/(60*60*24));
    diff_seconds -= diff_days * 60 * 60 * 24;
    document.getElementById("days").innerHTML=diff_days;    
    
    //Number of hours left
    var diff_hours = parseInt(diff_seconds/(60*60));
    diff_seconds -= diff_hours * 60 * 60;
    document.getElementById("hours").innerHTML=diff_hours;   

    //Number of minutes left
    var diff_minutes = parseInt(diff_seconds/(60));
    diff_seconds -= diff_minutes * 60;
    document.getElementById("minutes").innerHTML=diff_minutes; 

    document.getElementById("seconds").innerHTML=diff_seconds; 
    setTimeout("countdown();", 1000);
}
</script> 

</head>
<body>
According to the Mayans, the world ends in:
<table>
 <tr>
  <td>Years</td>
  <td>&nbsp;&nbsp;</td>
  <td>Days</td>
  <td>&nbsp;&nbsp;</td>
  <td>Hours</td>
  <td>&nbsp;&nbsp;</td>
  <td>Minutes</td>
  <td>&nbsp;&nbsp;</td>
  <td>Seconds</td>
 </tr>
 <tr>
  <td align="center"><span id="years"><script language="javascript">countdown();</script></span></td>
  <td>:</td>
  <td align="center"><span id="days"><script language="javascript">countdown();</script></span></td>
  <td>:</td>
  <td align="center"><span id="hours"><script language="javascript">countdown();</script></span></td>
  <td>:</td>
  <td align="center"><span id="minutes"><script language="javascript">countdown();</script></span></td>
  <td>:</td>
  <td align="center"><span id="seconds"><script language="javascript">countdown();</script></span></td>
 </tr>
</table>

 
Advertisements

Written by meditationatae

December 19, 2012 at 10:36 am

Posted in History

%d bloggers like this: