By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,814 Members | 2,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,814 IT Pros & Developers. It's quick & easy.

date function working in IE but not working in Mozill firefox3

P: 21
Hi sir,

I'have written small function in javascript for date (month and year), this is good working in IE at onclick event and current month-8 , year-2008 are displaying but in firefox3,opera,& sufari the current month - 8 and current year- 108 are showing.
I wanna current year in fire fox.

[code goes Here:]

Expand|Select|Wrap|Line Numbers
  1. function validateDate()
  2. {
  3. var d = new Date();
  4. var current_month = d.getMonth()+1;
  5. var current_year = d.getYear();
  6. alert(current_month + current_year);
  7. }
  8.  
Pls help me.

Thanks
Aug 7 '08 #1
Share this Question
Share on Google+
3 Replies


P: 28
Use this for the year part

Expand|Select|Wrap|Line Numbers
  1. var current_year = d.getUTCFullYear();

- Hussain
Aug 7 '08 #2

P: 21
Use this for the year part

Expand|Select|Wrap|Line Numbers
  1. var current_year = d.getUTCFullYear();

- Hussain

Thanks for alot for helping me.
Aug 7 '08 #3

acoder
Expert Mod 15k+
P: 16,027
If Universal Time is not important, then getFullYear() is fine too.
Aug 7 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.