Click here to Skip to main content
Rate this: bad
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 at 28-Feb-12 8:28am
Which line of code is failing in Mozilla?
priya from Madras at 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 at 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 at 28-Feb-12 8:43am
How about returning that value from the function, using this line:
return weekday[d.getDay()];
priya from Madras at 28-Feb-12 8:54am
ya nij checked with alert ,i.e) alert(weekday[d.getDay()]),
this also shows undefined
E.F. Nijboer at 28-Feb-12 11:11am
What is the value of dt and d in firefox?
priya from Madras at 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 at 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 Peter Leow 375
1 Sergey Alexandrovich Kryukov 330
2 Zoltán Zörgő 258
3 CHill60 195
4 TheRealSteveJudge 180
0 Sergey Alexandrovich Kryukov 8,853
1 OriginalGriff 6,631
2 Peter Leow 4,102
3 Zoltán Zörgő 3,714
4 Kornfeld Eliyahu Peter 2,525

Advertise | Privacy | Mobile
Web01 | 2.8.150123.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