- MomentJS Tutorial
- MomentJS - Home
- MomentJS - Overview
- MomentJS - Environment Setup
- MomentJS - Introduction
- MomentJS - Parsing Date And Time
- MomentJS - Date Validation
- MomentJS - Getter/Setter
- Manipulate Date And Time
- Formatting Date And Time
- MomentJS - Date Queries
- MomentJS - Internationalization
- MomentJS - Customization
- MomentJS - Durations
- MomentJS - Utilities
- MomentJS - Plugins
- MomentJS - Examples
- MomentJS Useful Resources
- MomentJS - Quick Guide
- MomentJS - Useful Resources
- MomentJS - Discussion
MomentJS - Using Locale in Browser
We can start working with locale by including the locale file in script tag. You can get the minified files for all locales from the MomentJS home page as shown below −
The same can be included in your application as shown here −
Example
<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>
Output
momentjs_internationalization.htm
Advertisements
To Continue Learning Please Login
Login with Google