GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Main page
  • Contents
  • Current events
  • Random article
  • About Wikipedia
  • Contact us
  • Help
  • Learn to edit
  • Community portal
  • Recent changes
  • Upload file
  • Special pages
  • Search
  • Donate

This view

  • Original page
  • New address

GeezerVison is showing en.wikipedia.org — File:JavaScript getYear Method Problem.png - Wikipedia

This is a file from the Wikimedia Commons
    File:JavaScript getYear Method Problem.png
    Size of this preview: 326 × 190 pixels.
    Original file (326 × 190 pixels, file size: 6 KB, MIME type: image/png)
    icon
    This is a file from the Wikimedia Commons. Information from its description page there is shown below.
    Commons is a freely licensed media file repository. You can help.

    Summary

    DescriptionJavaScript getYear Method Problem.png
    English: Webpage screenshots showing the JavaScript .getYear method problem. It depicts the so-called Year 2000 problem.

    The results of the .getYear method are different with Internet Explorer 6-8 and the other modern browsers:

    • IE3, IE9+, other modern browsers: .getYear always returns a 2-digit value that is the stored year minus 1900).
    • IE4-8, other modern browsers:
      • .getYear returns a 2-digit value that is the stored year minus 1900) for the years 1900 through 1999;
      • it returns the 4-digit full year for dates outside that range.

    .getYear is now obsoleted, but supported for backward compatibility by all modern browsers.

    .getFullYear is not supported before IE6. With those that support it, the 4-digit full year is always returned. This method is currently recommended.

    HTML and JavaScript code (by Tomchen1989 under CC0 1.0)
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <title>JavaScript .getYear Method Problem</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <style>
    table{border-collapse:collapse;}
    th,td{border:1px solid #000;}
    </style>
    </head>
    <body>
    <table>
    <tr>
    	<th>Real year</th>
    	<th>1858</th><th>1990</th><th>1994</th><th>2000</th><th>2007</th>
    </tr>
    <tr>
    	<th>.getYear() result</th>
    	<td id="getyear1"></td><td id="getyear2"></td><td id="getyear3"></td><td id="getyear4"></td><td id="getyear5"></td>
    </tr>
    <tr>
    	<th>.getFullYear() result</th>
    	<td id="getfullyear1"></td><td id="getfullyear2"></td><td id="getfullyear3"></td><td id="getfullyear4"></td><td id="getfullyear5"></td>
    </tr>
    </table>
    <script>
    var dates = [new Date("1858, 1, 1"), new Date("1990, 1, 1"), new Date("1994, 1, 1"), new Date("2000, 1, 1"), new Date("2007, 1, 1")];
    for (var i = 0; i < dates.length; i++) {
    	document.getElementById("getyear" + (i+1)).innerHTML = dates[i].getYear();
    	document.getElementById("getfullyear" + (i+1)).innerHTML = dates[i].getFullYear();
    }
    </script>
    </body>
    </html>
    

    BTW, if you want to return a 2-digit year value (only for AD, 3, 203, 1803, 1903 and 2003 all return "03", that are the last two digits) in modern browsers, you may try:

    ("0"+dateObj.getFullYear().toString()).slice(-2);
    

    References:

    • Date.prototype.getYear() - Mozilla Develope Network
    • getYear Method (Date) (JavaScript) - Internet Explorer Dev Center
    • getFullYear Method (Date) (JavaScript) - Internet Explorer Dev Center
    Date 2 May 2014, 20:25:38
    Source Own work
    Author Tomchen1989

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
    The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

    http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse

    Captions

    English
    Add a one-line explanation of what this file represents
    Simplified Chinese
    显示 JavaScript .getYear 方法问题的网页屏幕截图。 它描述了所谓的 2000 年问题。 .getYear 方法的结果与 Internet Explorer 6-8 和其他现代浏览器不同:IE3、IE9+、其他现代浏览器:.getYear 始终返回一个 2 位数的值,即存储的年份减去 1900)。 IE4-8,其他现代浏览器:.getYear 返回 1900 年到 1999 年的 2 位数字值,即存储的年份减去 1900); 对于该范围之外的日期,它返回 4 位数的全年。

    Items portrayed in this file

    depicts

    creator

    some value

    author name string: Tomchen1989
    Wikimedia username: Tomchen1989
    URL: https://commons.wikimedia.org/wiki/user:Tomchen1989

    copyright status

    copyrighted, dedicated to the public domain by copyright holder

    copyright license

    Creative Commons CC0 License

    inception

    2 May 2014

    source of file

    original creation by uploader

    data size

    6,431 byte

    height

    190 pixel

    width

    326 pixel

    media type

    image/png

    checksum

    7029967e9f0ced93ff79ed43c2609766760c6878

    determination method or standard: SHA-1

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current18:29, 2 May 2014Thumbnail for version as of 18:29, 2 May 2014326 × 190 (6 KB)Tomchen1989User created page with UploadWizard

    File usage

    The following 2 pages use this file:

    • Year 2000 problem
    • User:Rmmaily/sandbox

    Global file usage

    The following other wikis use this file:

    • Usage on el.wikipedia.org
      • Πρόβλημα του έτους 2000
    • Usage on es.wikipedia.org
      • Problema del año 2000
    • Usage on hu.wikipedia.org
      • A 2000. év problémája

    Metadata

    This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.

    If the file has been modified from its original state, some details may not fully reflect the modified file.

    Horizontal resolution28.34 dpc
    Vertical resolution28.34 dpc
    Software used
    • Adobe Fireworks CS6
    Date and time of digitizing
    • 05/02/14
    Retrieved from "https://en.wikipedia.org/wiki/File:JavaScript_getYear_Method_Problem.png"
    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.