problem with weekday name

Hi friends,
My code is given's displaying date & time of 3 different problem is with the 'weekday name' which is not correct...there is some problem in sequence of elements in weekday array...i.e.
var weekday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")

urgent help needed...

Meenakshi Dhar

Dim INDaspTime, USAaspTime, DENaspTime
INDaspTime = Now()
USAaspTime = DateAdd("n",-630,Now())
DENaspTime = DateAdd("n",-210,Now())

   var IndiaTime = new Date();
   var USATime = new Date();
   var DenmarkTime = new Date();

IndiaTime = TimeSetting(IndiaTime,<%=Day(INDaspTime)%>,<%=Month(INDaspTime)%>,<%=Year(INDaspTime)%>,<%=Hour(INDaspTime)%>,<%=Minute(INDaspTime)%>,<%=Second(INDaspTime)%>);
USATime = TimeSetting(USATime,<%=Day(USAaspTime)%>,<%=Month(USAaspTime)%>,<%=Year(USAaspTime)%>,<%=Hour(USAaspTime)%>,<%=Minute(USAaspTime)%>,<%=Second(USAaspTime)%>);

DenmarkTime = TimeSetting(DenmarkTime,<%=Day(DENaspTime)%>,<%=Month(DENaspTime)%>,<%=Year(DENaspTime)%>,<%=Hour(DENaspTime)%>,<%=Minute(DENaspTime)%>,<%=Second(DENaspTime)%>);

function TimeSetting(myDate,mDay,mMonth,mYear,mHour,mMinute,mSecond) {  
   return myDate;
function GetTimeString(mDate){
  var hours, minutes, seconds;
  var intHours, intMinutes, intSeconds;
  var vchday, vchmonth, vchyear;
  var vchdayname;      
  var weekday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
  var monthName=new Array("Dec","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov")

  vchday= mDate.getDate();
  intHours = mDate.getHours();
  intMinutes = mDate.getMinutes();
  intSeconds = mDate.getSeconds();
  hours = intHours+":";
  if (intHours < 10) {
     hours = "0"+intHours+":";
  } else {
     hours = intHours+":";
  if (intMinutes < 10) {
     minutes = "0"+intMinutes+":";
  } else {
     minutes = intMinutes+":";
  if (intSeconds < 10) {
     seconds = "0"+intSeconds+" ";
  } else {
     seconds = intSeconds+" ";
  timestring=vchdayname+", "+vchmonth+" "+vchday+", "+vchyear+" "+hours+minutes+seconds;
  return timestring;
function tick() {
  IndiaTimeDisplay.innerHTML = GetTimeString(IndiaTime);
  DenmarkTimeDisplay.innerHTML = GetTimeString(DenmarkTime);
  USATimeDisplay.innerHTML = GetTimeString(USATime);
  window.setTimeout("tick();", 1000);

<td>India&nbsp;&nbsp;<span class="3TimeDisplay" ID="IndiaTimeDisplay"></span></td>
<td>Denmark&nbsp;&nbsp;<span class="3TimeDisplay" ID="DenmarkTimeDisplay"></span></td>
<td>USA&nbsp;&nbsp;<span class="3TimeDisplay" ID="USATimeDisplay"></span></td>

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

First of all, it is not necessary for you to create custom arrays for this purpose. There are built-in functions for the same.

MonthName(month[, abbreviate]) gives you the month name

i.e. MonthName(1,True) returns "Jan" and MonthName(1,False) returns "January" and so on.

WeekdayName(weekday, abbreviate, firstdayofweek) gives you weekday name.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MyDateName = WeekDayName(6, True)   ' MyDateName contains "Fri".
MyDateName = WeekDayName(6, False)   ' MyDateName contains "Friday".

firstdayofweek can be optionally specified to state that the week starts from some other date than the default system weekstart date. 1 to 7 starts the week from sun to sat respectively. if omitted or specified as 0 system default is taken.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.