Days Left

Written by admin on December 25, 2008 – 7:59 am -

This script calculates and displays the number of days (not weekdays) left in the current month in a snap. And, the script has no trouble with leap year or Y2K.
Author: Justin Smith (jsmith@polbox.com)

<!-- ONE STEP TO INSTALL DAYS LEFT:

  1.  Copy the coding into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the BODY of your HTML document  -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var today = new Date();
var now = today.getDate();
var year = today.getYear();
if (year < 2000) year += 1900; // Y2K fix
var month = today.getMonth();

var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

// check for leap year
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monarr[1] = “29″;

// display day left
document.write(”There are ” + (monarr[month]-now) + ” days left in this Month.”);
//  End –>
</script>

<!– Script Size:  0.90 KB –>

Tags:
Posted in Calendar |

Post a Comment