Convert a date string '13.04.2018' into JavaScript Date object via regex - Javascript Date Operation

Javascript examples for Date Operation:Date Parse

Description

Convert a date string '13.04.2018' into JavaScript Date object via regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>convert a date string '13.04.2018' into JavaScript Date object</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from   w  ww. j  a v  a2  s . co m
var a = new Date( "13.04.2018".replace( /(\d{2}).(\d{2}).(\d{4})/, "$2/$1/$3") );
console.log(a);
    }

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

Related Tutorials