Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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,
JavaScript
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
JavaScript
( var dtday = weekday[d.getDay()];),

if am using
JavaScript
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
Updated 28-Feb-12 2:27am
v3
Comments
ZurdoDev 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

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:"http://www.w3schools.com/jsref/jsref_getday.asp[^]

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!
 
Share this answer
 
Comments
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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900