Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 854 Bytes

09-am-pm-parsing.md

File metadata and controls

41 lines (34 loc) · 854 Bytes
title version signature
AM/PM Parsing
2.1.0
// From 2.12.0 onward moment.updateLocale('en', { meridiemParse : RegExp isPM : Function }); // From 2.8.1 to 2.11.2 moment.locale('en', { meridiemParse : RegExp isPM : Function }); // Deprecated in 2.8.1 moment.lang('en', { meridiemParse : RegExp isPM : Function });

Locale#isPM should return true if the input string is past 12 noon. This is used in parsing the a A tokens.

moment.updateLocale('en', {
    isPM : function (input) {
        return ((input + '').toLowerCase()[0] === 'p');
    }
});

To configure what strings should be parsed as input, set the meridiemParse property.

moment.updateLocale('en', {
    meridiemParse : /[ap]\.?m?\.?/i
});