setUTCFullYear() Method JavaScript With Examples

setUTCFullYear() Method JavaScript With Examples

JavaScript: Date.setUTCFullYear() method. In this tutorial, you will learn how to set UTC full year in javascript with an example.

setUTCFullYear() Method JavaScript

Definition:- The javascript setUTCfullYear() method, which is used to sets the full year for a specified date according to Universal Time (UTC). This method accepts three-parameter values.

Syntax

Date.setUTCFullYear(year, month, day)

Parameters of setUTCFullYear() Method

ParameterDescription
yearThis is a first parameter and required. In this method year, negative values are allowed
monthThis is a second parameter and optional. You can pass values integer value from 0-11 in this parameter
day This is a third parameter and optional. You can pass values integer value from 1-31 in this parameter.

Example -1

Here we will take first example of setUTCFullYear method, without passing month and day:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript date.setUTCFullYear</title>
</head>
<body>
  <script type = "text/javascript">
     var date = new Date();
     date.setUTCFullYear(2025);
     document.write( "setUTCFullYear with year parameter: " + date );
  </script>  
</body>
</html>

Result of example 1 is:

JavaScript date.setUTCFullYear

Example – 2

Here we will take the second example of setUTCFullYear method, in this example, we will pass year and month in setUTCFullYear() method.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript date.setUTCFullYear with month</title>
</head>
<body>
  <script type = "text/javascript">
     var date = new Date();
     date.setUTCFullYear(2025, 9);
     document.write( "year, month parameter in setUTCFullYear() : " + date );
  </script>  
</body>
</html>

Result of example -2 is:

JavaScript date.setUTCFullYear with month

Example -3

Here we will take the third example of the setUTCFullYear method, in this example, we will pass all three parameters like year, month and day in setUTCFullYear() method.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript date.setUTCFullYear with year, month and day</title>
</head>
<body>
  <script type = "text/javascript">
     var date = new Date();
     date.setUTCFullYear(2025, 9, 12);
     document.write( "year, month and day parameter in setUTCFullYear() : " + date );
  </script>  
</body>
</html>

Result of example – 3 is:

JavaScript date.setUTCFullYear with year, month and day

Conclusion

In this javascript tutorial, you have learned how to sets a full year with year, month and day parameters using setUTCFullYear function with example.

You may like

  1. JavaScript: Date setUTCDate() Method
  2. Set UTC Month In javaScript
  3. JavaScript: Date.getUTCDate() Method
  4. getUTCmonth Method javaScript With Example
  5. javaScript Digital Clock with date
  6. JavaScript: Set Date Methods
  7. String Contains JavaScript | String includes() Method
  8. JavaScript Get Date Methods
  9. JavaScript Operators With Examples
  10. Sorting Using JavaScript Array Sort() Method
  11. JavaScript Replace String With Examples
  12. JavaScript Array splice() Method By Example
  13. JavaScript: Clone an Array & Object By Example
  14. Check the Object is Array or not in javascript

If you have any questions or thoughts to share, use the comment form below to reach us.

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *