get the first date of the current month - Javascript Date Operation

Javascript examples for Date Operation:Month

Description

get the first date of the current month

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Please Rate if it helps</title> 
      <script>
        Date.prototype.getMonthStartEnd = function (start) {
            var StartDate = new Date(this.getFullYear(), this.getMonth(), 1);
            var EndDate = new Date(this.getFullYear(), this.getMonth() + 1, 0);
            return [StartDate, EndDate];
        }// w  w w  . j ava  2  s. c  om
        window.onload = function () {
            document.write(new Date().getMonthStartEnd());
        }
    
      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials