Tutorialspoint

MomentJS Using Locale in Browser

<html>
   <head>
      <title>MomentJS - Adding locale</title>
      <script type="text/JavaScript" src="https://MomentJS.com/downloads/moment.js"></script>
      <script type="text/JavaScript" src="https://MomentJS.com/downloads/moment-with-locales.js"></script>
      <style>
         div {
            border: solid 1px #ccc;
            padding:10px;
            font-family: "Segoe UI",Arial,sans-serif;
            width: 40%;
         }
      </style>
   </head>
   <body>
      <h1>MomentJS - Adding locale</h1>
      <div style="font-size:25px" id="currentdate"></div>
      <br/>
      <br/>
      <div style="font-size:25px" id="changeddate"></div>
      <script type="text/JavaScript">
         moment.locale("pt");
         var a = moment().format('LLLL');
         moment.locale("hi");
         var b = moment().format('LLLL');
         document.getElementById("currentdate").innerHTML = "Output locale: " + a;
         document.getElementById("changeddate").innerHTML = "Output in hindi locale: " + b;
      </script>
   </body>
</html>

Advertisements
Loading...