Hi, I've written a simple script to test the current date and perform
an action depending on the result.
The problem is, the date displays correctly as a complete date in an
alert box but when I try to build the date from the components (i.e
d.getMonth() etc...) the result is an incorrect date.
How can the date be both correct and incorrect at the same time? The
intial alert(d); displays correctly, but the alert(t + "/" + m + "/" +
y); does not.
Is it heisenbergs uncertainty principle at work?
here's my code...
<script language="javascript" type="text/javascript">
var d;
d = new Date();
//get the date properties
t = d.getDay();
m = d.getMonth();
y= d.getYear();
//display the full date from the Date object.
alert(d);
//display the date for debugging purposes
alert(t + "/" + m + "/" + y);
//test if it's between April and September
if ((m > 4) && (m < 9))
{
//perform a conditional action
alert("out of the season");
}
else
{
alert("in the season");
}
</script>
it's a mystery... any ideas.
appreciated.
David Thomas.