Date.setYear() : setYear : Date JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Date » setYear »

 

Date.setYear()










Syntax








date.setYear(year)



The setYear() method sets the year in the Date object to the argument year. The argument can be either a four-digit or two-digit integer.

To create a two-digit representation, subtract 1900 from the desired date. The method returns an integer representing the number of milliseconds between midnight January 1, 1970 (GMT) to the new date.












<html>
    <script language="JavaScript">
    <!--
    theDate = new Date();

    document.write("Initial milliseconds=",theDate.getTime());
    document.write("<br>setYear returned ");
    document.write(theDate.setYear(83)," milliseconds.")
    document.write("<br>Final milliseconds=",theDate.getTime());

    -->
    </script>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Date
» setYear