Have year on 4 digits from a Date object

  function getYear(d) { 
    // Y2K-compliant and compatible IE and NS
    //   d  a Date object
    // returns a string 
    return (d=d.getYear())<1000 ? 1900+d : d
    }



If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2010
[ home ]