Date getMonth() Method - Javascript Date

Javascript examples for Date:getMonth


The getMonth() method returns the month from 0 to 11.

January is 0, February is 1, and so on.



Return Value:

A Number, from 0 to 11, representing the month

The following code shows how to return the month:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {//from ww  w .ja  va  2 s  . c o  m
    var d = new Date();
    var n = d.getMonth();
    document.getElementById("demo").innerHTML = n;


Related Tutorials