JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods
Arrays

JAVASCRIPT setUTCFullYear() METHOD

The setUTCFullYear() method in javascript sets the year in 4 digits in UTC (Universal Coordinated Time). Takes a compulsory year as a 4 digit number and an optional month and day parameter.

The general format is:

dateObject.setUTCFullYear(year, month,[optional], day[optional]);

If you want to return the full date with the setUTCFullYear() method, you will first have to create a new date object and then use the new date object with the setUTCFullYear() method.

Example 1: With only the year supplied

<script type="text/javascript">

var dd=new Date(); // creates a new date object

dd.setUTCFullYear(1989); // sets the date

document.write(dd); // outputs the date

</script>

The above will output:



Example 2: With all parameters supplied

<script type="text/javascript">

var dd=new Date(); // creates a new date object

dd.setUTCFullYear(1999, 11, 26); // sets the date

document.write(dd); // outputs the date

</script>

The above will output:



With the above, remember that in javascript, January is month 0 through to December which is month 11.

See Also:

getDate() getDay() getMonth()
getFullYear() getYear() getHours()
getMinutes() getSeconds() getTime()
getTimezoneOffset() parse() setDate()
setFullYear() setHours() setMinutes()
setMonth() setSeconds() setTime()
setYear() toGMTString() toLocaleString()
toString() getUTCDate() getUTCDay()
getUTCMonth() getUTCFullYear() getUTCHours()
getUTCMinutes() getUTCSeconds() getUTCMilliseconds()
setUTCDate() setUTCDay() setUTCMonth()
setUTCFullYear() setUTCHour() setUTCMinutes()
setUTCSeconds() setUTCMilliseconds()  
Home | Privacy Policy | Terms Of Use | Contact Us