meditationatae

Just another WordPress.com site

Winter solstice countdown, javascript code, version 2

<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;script language="JavaScript"&gt;<br /><br />function countdown(){<br />    //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<br />    expire = parseInt(Date.parse("Dec 21, 2012")/1000); //End Date<br />    var now = new Date();<br />    var current = parseInt(now.getTime()/1000);<br />    var diff_seconds = expire - current;<br /><br />    diff_seconds  = diff_seconds + 22297 ;<br /><br />    //Number of years left<br />    var diff_years = parseInt(diff_seconds/(60*60*24*365))<br />    diff_seconds -= diff_years * 60 * 60 * 24 * 365;<br />    document.getElementById("years").innerHTML=diff_years;<br /><br />    //Number of days left<br />    var diff_days = parseInt(diff_seconds/(60*60*24));<br />    diff_seconds -= diff_days * 60 * 60 * 24;<br />    document.getElementById("days").innerHTML=diff_days;    <br />    <br />    //Number of hours left<br />    var diff_hours = parseInt(diff_seconds/(60*60));<br />    diff_seconds -= diff_hours * 60 * 60;<br />    document.getElementById("hours").innerHTML=diff_hours;   <br /><br />    //Number of minutes left<br />    var diff_minutes = parseInt(diff_seconds/(60));<br />    diff_seconds -= diff_minutes * 60;<br />    document.getElementById("minutes").innerHTML=diff_minutes; <br /><br />    document.getElementById("seconds").innerHTML=diff_seconds; <br />    setTimeout("countdown();", 1000);<br />}<br />&lt;/script&gt; <br /><br />&lt;/head&gt;<br />&lt;body&gt;<br />According to the Mayans, the world ends in:<br />&lt;table&gt;<br /> &lt;tr&gt;<br />  &lt;td&gt;Years&lt;/td&gt;<br />  &lt;td&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;<br />  &lt;td&gt;Days&lt;/td&gt;<br /><br />  &lt;td&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;<br />  &lt;td&gt;Hours&lt;/td&gt;<br />  &lt;td&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;<br />  &lt;td&gt;Minutes&lt;/td&gt;<br />  &lt;td&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;<br />  &lt;td&gt;Seconds&lt;/td&gt;<br /> &lt;/tr&gt;<br /><br /> &lt;tr&gt;<br />  &lt;td align="center"&gt;&lt;span id="years"&gt;&lt;script language="javascript"&gt;countdown();&lt;/script&gt;&lt;/span&gt;&lt;/td&gt;<br />  &lt;td&gt;:&lt;/td&gt;<br />  &lt;td align="center"&gt;&lt;span id="days"&gt;&lt;script language="javascript"&gt;countdown();&lt;/script&gt;&lt;/span&gt;&lt;/td&gt;<br />  &lt;td&gt;:&lt;/td&gt;<br />  &lt;td align="center"&gt;&lt;span id="hours"&gt;&lt;script language="javascript"&gt;countdown();&lt;/script&gt;&lt;/span&gt;&lt;/td&gt;<br /><br />  &lt;td&gt;:&lt;/td&gt;<br />  &lt;td align="center"&gt;&lt;span id="minutes"&gt;&lt;script language="javascript"&gt;countdown();&lt;/script&gt;&lt;/span&gt;&lt;/td&gt;<br />  &lt;td&gt;:&lt;/td&gt;<br />  &lt;td align="center"&gt;&lt;span id="seconds"&gt;&lt;script language="javascript"&gt;countdown();&lt;/script&gt;&lt;/span&gt;&lt;/td&gt;<br /> &lt;/tr&gt;<br />&lt;/table&gt;<br /><br /><br />

Advertisements

Written by meditationatae

December 19, 2012 at 10:51 am

Posted in History

%d bloggers like this: