469,271 Members | 1,641 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

date function working in IE but not working in Mozill firefox3

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
3 1528
Use this for the year part

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

- Hussain
Aug 7 '08 #2
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
16,027 Expert Mod 8TB
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.

Similar topics

7 posts views Thread by vnl | last post: by
12 posts views Thread by Assimalyst | last post: by
10 posts views Thread by Daniel | last post: by
5 posts views Thread by krishna.tunikipati | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.