How to use the locale function from moment

Find comprehensive JavaScript moment.locale code examples handpicked from public code repositorys.

22
23
24
25
26
27
28
29
30
31
  $translate,
  SetLanguageCookie
) {
  'ngInject';
  return function(code, setLanguageCookie) {
    moment.locale([code, 'en']);
    $translate.use(code);

    if (setLanguageCookie !== false) {
      SetLanguageCookie(code);
fork icon185
star icon408
watch icon53

2
3
4
5
6
7
8
9
10
11
let moment = require('moment');
require("moment/min/locales.min");

$(document).ready(function () {
    let language = $('html').attr('lang');
    moment.locale(language);

    $('.moment').each(function() {
        date = $(this).text()
        $(this).text(moment(date).format('LL'))
fork icon147
star icon315
watch icon13

5
6
7
8
9
10
11
12
13
14
const i18n = require('i18n')
const constants = require('./constants')
const withTemplate = require('./template')
const models = require('../../models')

// moment.locale('pt-br', ptLocale)

const setMomentLocale = (lang) => {
  if (lang === 'br') {
    moment.locale('pt-br', ptLocale)
fork icon145
star icon153
watch icon14

+ 5 other calls in file

47
48
49
50
51
52
53
54
55
56
// Set IP Address and Port
app.set('host', process.env.HOST || '127.0.0.1');
app.set('port', process.env.PORT || 3000);

// set locale as date and time format
moment.locale(config.locale);

// Setup Views
if (!config.theme_dir)  { config.theme_dir  = path.join(__dirname, '..', 'themes'); }
if (!config.theme_name) { config.theme_name = 'default'; }
fork icon450
star icon0
watch icon95

+ 3 other calls in file