MomentJs Changing Locales Locally


index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MomentJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script type="text/javascript" src="moment.js"></script>
<script type="text/javascript" src="locale/ne.js"></script>
<script type="text/javascript" src="locale/hi.js"></script>
<style type="text/css">
*{
font-family: arial;
}
p{
padding: 5px;
background-color: red;
color:white;
}
</style>
</head>
<body>
<script>
jQuery(document).ready(function($) {
moment.locale('en'); // default the locale to English
var localLocale = moment();

moment.locale('ne'); // change the global locale to Nepalese
var ne1 = localLocale.format('LLLL'); // dimanche 15 juillet 2012 11:01
var ne2 = moment().format('LLLL'); // Domingo 15 Julio 2012 11:01
console.log(ne1);
console.log(ne2);

moment.locale('hi'); // change the global locale to Hindi
var hi1 = localLocale.format('LLLL'); // dimanche 15 juillet 2012 11:01
var hi2 = moment().format('LLLL'); // Domingo 15 Julio 2012 11:01
console.log(hi1);
console.log(hi2);

$('.ne1').text(ne1);
$('.ne2').text(ne2);

$('.hi1').text(hi1);
$('.hi2').text(hi2);
});
</script>
<p class="ne1"></p>
<p class="ne2"></p>
<p class="hi1"></p>
<p class="hi2"></p>
</body>
</html>
-------------------------------------
DEMO:


Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

1 comments:

  1. The King Casino: The New King & The World of Gaming
    The King Casino is the new https://jancasino.com/review/merit-casino/ place where the real goyangfc.com money titanium flat iron gambling is legal in Florida and Pennsylvania. aprcasino We love the new casino. We've got some great

    ReplyDelete