Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Javascript JavaScript method setFullYear()

Related Tutorials


 
 

Share on Google+Share on Google+

JavaScript method setFullYear()

Advertisement
setFullYear() method is used to set the full year for the specified date according to local time.

JavaScript method setFullYear()

     

This section illustrates you the use of JavaScript method setFullYear()

setFullYear() method is used to set the full year for the specified date according to local time. In the given example, we have created a date object and specify date and time to it. Then we have used the method setFullYear() and specify 2008 as a parameter. When this html page is loaded, you will see that the year you have specified in the date object has been changed to 2008. You can also specify month and day value as a parameter.

Its syntax is:

dateObject.setFullYear(year,month,day)

year - a numeric value representing the year, e.g. 2008.
month -  a numeric value representing the month (0 to 11).
day - a numeric value representing the day of the month (1 to 31). If you want to specify this parameter ,you have to specify the month..

Here is the code:

<html>
<h2>Use of setFullYear() Method</h2>
<script type="text/javascript">
var date = new Date("Feb 5, 2009 01:35:00");
date.setFullYear(2008);
document.write("The new Date and Time is: <b>"+date+"</b>"); 
</script>
</html>

Output will be displayed as:

Download Source Code:

     

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 11, 2009

Related Tutorials

Discuss: JavaScript method setFullYear()   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com