Date format DD/MM/YYYY

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 JavaScript to also use that
format.

Many thanks

The code
------------------------------------
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
}
 
E

Erwin Moller

Yas schreef:
<snip>

Hi Yas,

We all saw your posting from 3 hours ago just fine.
No need to repost the same question so fast.

If you are lucky somebody fixes your code.
I will not fix it because it is so basic.
You should be able to do it yourself, which you didn't try.
(At least you didn't show us anything.)

I don't want to be rude, or lecture you, but....
In general, just asking to fix your problem in a newgroup doesn't result
in a solution/many responses.
People think you are lazy, and should do it yourself.
(We get paid most of the time to fix other peoples problems, you know..)

However, if you ask something after trying yourself, AND show us what
you tried, you might get much better responses.

(Just a freindly word of advise.)

Regards,
Erwin Moller
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top