getMonth() javascript method returns the month of the Date and values are (0-11) 0 for January and 11 for December.
If today was "2015-03-01" (first day of March 2015), getMonth() should return 2 but instead it returns 1. Why is this? how can I solve this issue?
Help!!
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Date Example</h2>
<p id="demo"></p>
<script>
var x = new Date("2015-03-01");
document.getElementById("demo").innerHTML = x.getMonth();
</script>
</body>
</html>
When I "Run code Snippet" It shows this: