problem with weekday name

Posted on 2004-11-30
Last Modified: 2012-08-14
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>

Question by:MeenakshiDhar
    LVL 8

    Accepted Solution

    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.

    LVL 8

    Expert Comment

    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.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now