problem with weekday name

Posted on 2004-11-30
Medium Priority
Last Modified: 2012-08-14
Hi friends,
My code is given below...it's displaying date & time of 3 different countries...my 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
  • 2

Accepted Solution

fozylet earned 400 total points
ID: 12714494
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.


Expert Comment

ID: 12714524
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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline
Suggested Courses

807 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