C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Date getMonth() methodThe JavaScript date getMonth() method returns the integer value that represents month in the specified date on the basis of local time. The value returned by getMonth() method starts with 0 that represents January. SyntaxThe getMonth() method is represented by the following syntax: dateObj.getMonth() ReturnAn integer value between 0 and 11 that represents the month in the specified date. JavaScript Date getMonth() method exampleHere, we will understand getMonth() method through various examples. Example 1Let's see an example to print current month. <script> var date=new Date(); document.writeln(date.getMonth()+1); </script> Output: 7 Example 2Let's see an example to print the month from the given date. <script> var date=new Date("August 15, 1947 20:22:10"); document.writeln(date.getMonth()+1) </script> Output: 8
Next TopicJavaScript Math
|