Replacing Numerical Months into Words in JavaScript - Javascript String Operation

Javascript examples for String Operation:String Replace

Description

Replacing Numerical Months into Words in JavaScript

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(){/*ww  w  . j  a v a  2  s . co m*/
var monthNames=['JAN','FEB','MAR','APR','MAY'],
    date='2010-01-23',
    m=date.match(/-(\d\d)-/),
    newdate=date.replace(/-\d\d-/,'-'+monthNames[(RegExp.$1-1)]+'-');
console.log(newdate);
    });

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

Related Tutorials