Date format

Y

Yas

Hello I've got the following Javascript for a web calendar popup that
outputs the date in 4/24/2008 (m/d/yyyy).

How can i modify it to output dd/mm/yyyy e.g. 24/04/2008. So all
outputs are in this format. The system this runs on has the correct
date format (not US) so I would like the JScript to also use that
format.

Many thanks



var OneDay = 86400000
var OneMonth = (OneDay * 30)
var CurrentDate = new Date()
varCurrentMonth = ""
varMonth = new Array(12)
varMonth[1] = "January"
varMonth[2] = "February"
varMonth[3] = "March"
varMonth[4] = "April"
varMonth[5] = "May"
varMonth[6] = "June"
varMonth[7] = "July"
varMonth[8] = "August"
varMonth[9] = "September"
varMonth[10] = "October"
varMonth[11] = "November"
varMonth[12] = "December"
varActiveTBox = ""
varTop = "100"
varLeft = "100"

function DatePicker(TheDate,e,top,left)
{
varActiveTBox = e
varTop = top
varLeft = left
var RefDate = new Date(TheDate)
varDays = RefDate.getTime() - (OneDay * (RefDate.getDate()-1))
RefDate.setTime(varDays)
varDays = RefDate.getTime() - (OneDay * (RefDate.getDay()))
RefDate.setTime(varDays)
var MnthDate = new Date(TheDate)
varDays = RefDate.getTime() + (OneDay * 15)
MnthDate.setTime(varDays)
varCurrentMonth = varMonth[MnthDate.getMonth()+1] + " " +
MnthDate.getYear()
CurrentDate = TheDate
ShowCalendar(RefDate);
}

function Prev()
{
var pDate = new Date(CurrentDate);
varpDays = pDate.getTime() - OneMonth;
pDate.setTime(varpDays);
DatePicker(pDate,varActiveTBox,varTop,varLeft);
}

function Next()
{
var nDate = new Date(CurrentDate);
varnDays = nDate.getTime() + OneMonth;
nDate.setTime(varnDays);
DatePicker(nDate,varActiveTBox,varTop,varLeft);
}

function ShowCalendar(theDate){
calendar.innerHTML = "";
var DateLoop = new Date(theDate);

var varCal ="<table border='0' cellspacing='2' cellpadding='1'
class='calendar' style='left: " + varLeft + "px; TOP: " + varTop +
"px'>";
varCal += "<tr><td onClick=Prev() class='clicker'><</td>";
varCal += "<td colspan='5' align='center' class='calheader'>" +
varCurrentMonth +"</td>";
varCal += "<td onClick=Next() class='clicker'>></td></tr>";

for ( var r = 1; r <= 6; r++ ) {
varCal += "<tr>"

for ( var c = 1; c <= 7; c++ ) {
varCal += "<td align='right' onClick=ShowDate('"
varCal += DateLoop.getMonth()+1 + "/" + DateLoop.getDate() + "/" +
DateLoop.getYear()
varCal += "') class='calday'>" + DateLoop.getDate() + "</td>";
varDays = DateLoop.getTime() + OneDay;
DateLoop.setTime(varDays);


}
varCal += "</tr>"
}
varCal += "</table>"
calendar.innerHTML = varCal
}

function ShowDate(theDate)
{
var myDate = new Date(theDate)

calendar.innerHTML = ""
varActiveTBox.value = theDate
}
 
D

Dr J R Stockton

In comp.lang.javascript message <dd5b4839-f511-43de-8db2-03947e7321f5@b6
4g2000hsa.googlegroups.com>, Fri, 18 Apr 2008 01:19:16, Yas
Hello I've got the following Javascript for a web calendar popup that
outputs the date in 4/24/2008 (m/d/yyyy).

It's rubbish. Delete it.
Firefox is 2.0.0.14

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top