Click here to Skip to main content
11,920,641 members (55,715 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
am using date picker ,when i choose the date , it shows lik 28/02/2012, i need to get the day(tuesday) from the date .am using lik this,
function date()
var dt = $get("<%=deliveryTime.ClientID %>").value;
var d = new Date(dt);
                        var weekday = new Array(7);
                        weekday[0] = "Sunday";
                        weekday[1] = "Monday";
                        weekday[2] = "Tuesday";
                        weekday[3] = "Wednesday";
                        weekday[4] = "Thursday";
                        weekday[5] = "Friday";
                        weekday[6] = "Saturday";
                     var dtday = weekday[d.getDay()];

In IE its working fine , But in mozilla ,it shows undefined,but instead of this
( var dtday = weekday[d.getDay()];),
if am using
document.write("Today is " + weekday[d.getDay()]);

it shows the correct day , How could i get the day in mozilla

[edit]Code block added - OriginalGriff[/edit]
Posted 28-Feb-12 3:24am
Edited 28-Feb-12 3:27am
ryanb31 28-Feb-12 8:28am
Which line of code is failing in Mozilla?
priya from Madras 28-Feb-12 8:30am
( var dtday = weekday[d.getDay()];),this one

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is almost the exact example as given on w3cschool. If I execute it in firefox it doesn't give any errors. Try their example directly on the site:"[^]

This would mean that $get("<%=deliveryTime.ClientID %>").value isn't returning a valid date. I can't see what the value is, but I would check it out.

Good luck!
priya from Madras 28-Feb-12 8:39am
ya actually u r correct , am using the same example but when i use

document.write("Today is " + weekday[d.getDay()]);

it shows the day , but i want to pass the day lik argument so i need to assign lik

var dtday = weekday[d.getDay()];

but var dtday = weekday[d.getDay()]; this part is not working , shows undefined
E.F. Nijboer 28-Feb-12 8:43am
How about returning that value from the function, using this line:
return weekday[d.getDay()];
priya from Madras 28-Feb-12 8:54am
ya nij checked with alert ,i.e) alert(weekday[d.getDay()]),

this also shows undefined
E.F. Nijboer 28-Feb-12 11:11am
What is the value of dt and d in firefox?
priya from Madras 29-Feb-12 4:54am
dt is date lik Mon 29/02/2012 d is value lik 1 or 2 something lik that
E.F. Nijboer 1-Mar-12 3:28am
I think the error is because of the 'Mon' part in the date. If that would be stripped off it should work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 415
1 phil.o 170
2 Dave Kreskowiak 155
3 KrunalRohit 134
4 F-ES Sitecore 130
0 OriginalGriff 6,778
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,203
3 George Jonsson 2,815
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web03 | 2.8.151120.1 | Last Updated 28 Feb 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100