L
Luis
I've adapted the following code so that it prints the date in
DD/MM/YYYY format. However it prints the incorrect date! If todays
date is 01/01/2003 it prints 03/01/2003 - 3 days out! What have I done
wrong?
<script language="Javascript">
aCalendar = new Date();
CalendarDay = aCalendar.getDay();
CalendarMonth = aCalendar.getMonth();
CalendarDate = aCalendar.getDate();
CalendarYear = aCalendar.getYear();
var monthname = new Array ("01", "02", "03", "04", "05", "06", "07",
"08", "09", "10", "11", "12" );
var dayname = new Array ("01", "02", "03", "04", "05", "06", "07",
"08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18",
"19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
"30", "31" );
if (CalendarDate < 10) MonthSize=("0" + CalendarMonth + "/");
else MonthSize=(CalendarDate + "/");
if (CalendarDate < 10) DaySize=("0" + CalendarDay + "/");
else DaySize=(CalendarDate + "/");
var TheDateIs = dayname[CalendarDay] + "/" + monthname[CalendarMonth]
+ "/" + CalendarYear
document.write("Todays date is: " + TheDateIs)
</script>
If I change
CalendarDay = aCalendar.getDay();
to:
CalendarDay = aCalendar.getDay()-3;
it displays the correct date. But isn't there a better solution?
I need the date in DD/MM/YYYY format, ie 01/01/2003
DD/MM/YYYY format. However it prints the incorrect date! If todays
date is 01/01/2003 it prints 03/01/2003 - 3 days out! What have I done
wrong?
<script language="Javascript">
aCalendar = new Date();
CalendarDay = aCalendar.getDay();
CalendarMonth = aCalendar.getMonth();
CalendarDate = aCalendar.getDate();
CalendarYear = aCalendar.getYear();
var monthname = new Array ("01", "02", "03", "04", "05", "06", "07",
"08", "09", "10", "11", "12" );
var dayname = new Array ("01", "02", "03", "04", "05", "06", "07",
"08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18",
"19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
"30", "31" );
if (CalendarDate < 10) MonthSize=("0" + CalendarMonth + "/");
else MonthSize=(CalendarDate + "/");
if (CalendarDate < 10) DaySize=("0" + CalendarDay + "/");
else DaySize=(CalendarDate + "/");
var TheDateIs = dayname[CalendarDay] + "/" + monthname[CalendarMonth]
+ "/" + CalendarYear
document.write("Todays date is: " + TheDateIs)
</script>
If I change
CalendarDay = aCalendar.getDay();
to:
CalendarDay = aCalendar.getDay()-3;
it displays the correct date. But isn't there a better solution?
I need the date in DD/MM/YYYY format, ie 01/01/2003