smahmud Posted October 27, 2006 Share Posted October 27, 2006 Hi friends,I am new to HTML/Jscript. I am getting an error from this line of the following code snippet. The error says that getmonth() is not a valid method for today of type date().this_month = today.getmonth()Please help figuring out the mystry.Thanks.Sean.========================================HTML><HEAD><script language="javascript">function get_quarter(){var today = new Date()this_month = today.getmonth()this_year = today.getyear()switch(this_month){case 0,1,2:return this_year+'1'case 3,4,5:return this_year+'2'case 6,7,8:return this_year+'3'case 9,10,11:return this_year+'4'}function say_it(){document.write("The current quarter is " + get_quarter());}</script></HEAD><BODY><script language="JavaScript">say_it();</script></BODY></HTML> Link to comment Share on other sites More sharing options...
jesh Posted October 27, 2006 Share Posted October 27, 2006 Rather than today.getmonth()today.getyear() Try: today.getMonth();today.getYear(); Link to comment Share on other sites More sharing options...
smahmud Posted October 27, 2006 Author Share Posted October 27, 2006 Rather thantoday.getmonth()today.getyear() Try: today.getMonth();today.getYear(); Thanks Jesh.That did not work. Following is even a smaller example with the same problem. Please help:======================================================<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled</title><script type="text/javascript">function showdate(){var d=new Date();var t= d.getmonth();document.write(d.getMonth());}</script></head><body><script type="text/javascript">showdate();</script></body></html> Link to comment Share on other sites More sharing options...
scott100 Posted October 27, 2006 Share Posted October 27, 2006 That did not work. Following is even a smaller example with the same problem. Please help:You have forgot this line, change the m to uppercasevar t= d.getmonth(); function showdate(){var d=new Date();var t= d.getMonth();document.write(t);} Link to comment Share on other sites More sharing options...
justsomeguy Posted October 27, 2006 Share Posted October 27, 2006 Also, getYear is not officially a part of Javascript. Use getFullYear instead. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now