»
EnglishFrenchVietnamese

Print - Event Countdown script - JavaScriptBank.com

Full version: jsB@nk » Time » Counter » Event Countdown script
URL: http://www.javascriptbank.com/event-countdown-script.html

Event Countdown script © JavaScriptBank.comAn easy-to-use countdown script which can also count towards a specific amount of days (e.g., day 12 of 30). (Additional uses listed in script).

Full version: jsB@nk » Time » Counter » Event Countdown script
URL: http://www.javascriptbank.com/event-countdown-script.html



JavaScript
<script language="javascript"><!--/*Created by: James Crooke :: http://www.cj-design.com** Additional formats can be seen on the Web site at:http://www.cj-design.com/demos/cjeventcountdownv1/ */function renderMessage(dateStr, msg1, msg2, countFrom) {  var date = new Date(dateStr);  var now = new Date();  var diff = date.getTime() - now.getTime();  var days = Math.floor(diff / (1000 * 60 * 60 * 24)) + 1;  if(days < 1) {    document.write(msg1);  } else {    if(countFrom)      days = countFrom - days;    document.write(msg2.replace(/%days%/g, number_format(days)));  }}function number_format(num) {  num = num.toString().replace(/\$|\,/g,'');  if(isNaN(num)) {    num = "0";  }  sign = (num == (num = Math.abs(num)));  num = Math.floor(num*100+0.50000000001);  num = Math.floor(num/100).toString();  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)  num = num.substring(0,num.length-(4*i+3))+','+  num.substring(num.length-(4*i+3));  return (((sign)?'':'-') + num);}// --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<script type="text/javascript"><!--  // 1st parameter: "target date", 2nd parameter: "late message", 3rd parameter: "early message".  renderMessage("December 11, 2008", "You missed it!!", "Hurry, there's only %days% days to go!");//--></script></blockquote><p>In this example, the date is set to <strong>November 15, 2005</strong>, a date which has passed...</p><blockquote><script type="text/javascript"><!--  renderMessage("November 15, 2005", "You missed it!", "Hurry, there's only %days% days to go!");//--></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->