Results 1 to 3 of 3

Thread: How to use PHP get year in firefox ?

  1. #1
    Join Date
    May 2008
    Posts
    372

    How to use PHP get year in firefox ?

    Hello,

    I would use the getYear in FireFox, but it does not display correctly.

    Code:
    <html> 
    <body> 
    <script type="text/javascript"> 
    var d = new Date () 
    document.write ( "2005 -" + d.getYear ()) 
    </ script> 
    </ body> 
    </ html>

    Perfect in IE but in FireFox, nothing works (bad display).

    Can anyone help me?

    Thank you very much!

  2. #2
    Join Date
    May 2008
    Posts
    249

    Re: How to use PHP get year in firefox ?

    Did you think of those who have javascript disabled?

    Your site should work well without javascript. The javascript in my opinion just to serve retail, to make something nice (like holding a CSS) and should not be essential for the proper functioning of your site.

  3. #3
    Join Date
    May 2008
    Posts
    376

    Re: How to use PHP get year in firefox ?

    You should be use getFullYear () instead of getYear ();

    Before 2000, getYear () returned 98 for 1998. Firefox has therefore continue as follows: 1999 = 99 and therefore 2000 = 100 2001 = 101 ... etc

    Javascript is very useful and it depends on what tests you do.
    getFullYear () you will return in 2006 in Firefox and IE ...

    or you can use getYear () and simply add 1900 if necessary:
    var d = new Date ();
    var year = d.getFullYear ();

    Code only for the year:

    Code:
    Date.prototype.getTwoDigitYear = function () {return /(\d{2})$/.test (this.getFullYear()) ? RegExp.$1 : this}

Similar Threads

  1. Replies: 8
    Last Post: 27-11-2011, 06:47 PM
  2. Download Firefox Aurora, Firefox Nightly and Firefox Beta
    By Johnny in forum Web News & Trends
    Replies: 1
    Last Post: 21-08-2011, 05:02 PM
  3. Firefox Announces Firefox 6 Beta and Firefox 7 Aurora
    By Eseld in forum Technology & Internet
    Replies: 5
    Last Post: 20-07-2011, 07:48 PM
  4. How to write a program to determine if year is leap year or not
    By Luis-Fernando in forum Software Development
    Replies: 4
    Last Post: 30-11-2009, 05:21 PM
  5. How to get out of 2 year contract with AT&T
    By Zacharia in forum Portable Devices
    Replies: 3
    Last Post: 24-08-2009, 06:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,345,027.99631 seconds with 16 queries