Reposition Date String to locale - Javascript Date

Javascript examples for Date:toLocaleString

Description

Reposition Date String to locale

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from ww w.  j  a  va2 s . co  m*/
String.prototype.toLocaleString = function (locale) {
    if (locale == "de-de") return this.replace(/(\d+).(\d+).(\d+)/, '$2.$1.$3');
}
console.log('01.02.2013'.toLocaleString("de-de"));
    }

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

Related Tutorials