Set the full year for a specified date according to universal time.

HTMLJavascriptProgramming Scripts

<p style="">JavaScript date setUTCFullYear() method sets the full year for a specified date according to universal time.</p><p style="">The following are the parameters for setUTCFullYear(yearValue[, monthValue[, dayValue]]) &minus;</p><ul class="list"><li><strong>yearValue</strong> &minus; An integer specifying the numeric value of the year, for example, 2008.</li><li><strong>monthValue</strong> &minus; An integer between 0 and 11 representing the months January through December.</li><li><strong>dayValue</strong> &minus; An integer between 1 and 31 representing the day of the month. If you specify the dayValue parameter, you must also specify the monthValue.</li></ul><h2>Example</h2><p style="">You can try to run the following code to set the full year for a specified date according to universal time &minus;</p><pre class="prettyprint notranslate">&lt;html&gt; &nbsp; &nbsp;&lt;head&gt; &nbsp; &nbsp; &nbsp; &lt;title&gt;JavaScript setUTCFullYear Method&lt;/title&gt; &nbsp; &nbsp;&lt;/head&gt; &nbsp; &nbsp;&lt;body&gt; &nbsp; &nbsp; &nbsp; &lt;script&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var dt = new Date( &quot;Aug 28, 2012 23:30:00&quot; ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dt.setUTCFullYear( 2018 ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;document.write( dt ); &nbsp; &nbsp; &nbsp; &lt;/script&gt; &nbsp; &nbsp;&lt;/body&gt; &lt;/html&gt;</pre>
raja
Updated on 23-Jun-2020 08:16:39

Advertisements