.

TAXES

TECHNOLOGY

SERVICES

CRYSTAL COMPUTER CONCEPTS

DELAWARE'S   ·      MIDDLETOWN  ·     ODESSA  ·    TOWNSEND AREA

For time and date functions written in JavaScript you must:.

  1. Declare a variable with the keyword: var.
  2. End the declaration with a ; simicolon.
  3. Important, each and every statement must end with a semicolon--.
  4. Begin the date time function with the key word: new.
  5. Attach the properties to the variable.
  6. Use the proper syntax to attach a property as var.property
For example, the script may be written as follows:
<script type="text/javascript">
var d =new Date();
document.write(d + "<br />");
document.write(d.getTime() + " miliseconds since 1970/01/01" + "<br />");
</script>

RESULTS


Note: Time is reported in milliseconds since 1970 for JavaScript. This requires a math conversion.

Divide days by the milleseconds in day, as determined by multiplying the following 4 values.
24 X 60 X 60 X 1000 = 86,400,000
hours in a day minutes in a hour seconds in a minute 1000 milliseconds
in a second

Now we will use Javascript to calculate the days to April 15, known as tax day.

First we need two methods attached to the date object to get to Apr. 15th. Next an if statement is needed
to determine if we are passed Apr. the 15th of the current year or if the date did not yet occur.

The Script that produced what is on the left looks like this:

<script type="text/javascript">
var APR15=new Date();//Here we instantiate the Date object for use.
APR15.setFullYear(APR15.getFullYear(),3,15);//Here we are setting to a specific date.
document.write("Current Year's April 15, " + APR15.getFullYear() );
var today=new Date();//Here we re-assign the date object to today.
document.write("<br />")

if (APR15>today)
	{ var Dayto15= (APR15-today);
	document.write("<p> JavaScript time to the next Apr. 15th: " + Dayto15 + "<br /> which is ridiculous!</p>");
	var DayConv=(Dayto15)/(1000*60*60*24);
	DayConv=Math.round(DayConv);
	document.write(DayConv + ": Days until next April 15th");	
}
else
{	APR15.setFullYear(APR15.getFullYear()+1,3,15); 
	//document.write("<p>Coming April 15: " + APR15 + "</p>");
	var Dayto15 =(APR15-today);
	document.write("<p> JavaScript time to the next Apr. 15th: " + Dayto15 + "<br /> which is ridiculous!</p>");
	var DayConv=(Dayto15)/(1000*60*60*24);
	DayConv=Math.round(DayConv);
	document.write(DayConv + ": Days until next April 15th");
}

</script>

Return to Table of Contents


DELAWARE'S MIDDLETOWN ODESSA AND TOWNSEND AREA