471,887 Members | 760 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

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 1593
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
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.