Now you can listen to this article with the Online Text Reader

JavaScript getUTCMonth Method

The getUTCMonth method returns, according to universal time, the month of the point in stored in a Date object. The value returned by this method is an integer number from 0 to 11, zero being January and eleven being December.



With myDate being an object based on the Date object.


The following code uses the getUTCMonth method to return the month of the current date according to universal time.

<script type="text/javascript">

function getMonthName(monthNumber)
  var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  return monthNames[monthNumber];

var currentDate = new Date();
var universalMonthNumber = currentDate.getUTCMonth();
var nameOfTheMonth = getMonthName(universalMonthNumber);

document.write("According to universal time the number of the current month is " + universalMonthNumber + ",  which means it is " + nameOfTheMonth + ".");


Technical Details

The getUTCMonth 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 >> getUTCMonth Method

© Copyright 2010-2018 ROM Cartridge

Books to Read and Listen to Online