Get the month out of a MySQL timestamp using JS - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:jQuery Method Example

Description

Get the month out of a MySQL timestamp using JS

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.5.2.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   w  w w .  j a v  a 2  s  . c o  m*/

var month=new Date('2018-05-03 12:00:00').getMonth() + 1;
var month2=('2018-05-03 12:00:00').split('-')[1];
console.log(month+' or '+month2);

    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials