JavaScript getUTCFullYear Method





The getUTCFullYear method returns, according to universal time, the year of the point in time stored in a Date object. The value returned by this method is an integer number with all the digits of the year in question.


Syntax

myDate.getUTCFullYear()

With myDate being an object based on the Date object.


Example

The following code uses the getUTCFullYear method to return the year of the current date according to universal time:

<script type="text/javascript">

var currentDate = new Date();
var universalCurrentYear = currentDate.getUTCFullYear();

document.write("According to universal time, the current year is: " + universalCurrentYear + ".");

</script>



Technical Details

The getUTCFullYear method belongs to the Date object, it is available since the version 1.3 of JavaScript, and it is supported in all major browsers.





JavaScript Manual >> Date Object >> getUTCFullYear Method





© Copyright 2010-2016 ROM Cartridge