This is the most robust display option. It takes a string of tokens and replaces them with their corresponding values.

    was added in 2.0.0.

    e E gg gggg GG GGGG were added in 2.1.0.

    x was added in 2.8.4.

    SSSS to SSSSSSSSS were added in 2.10.5. They display 3 significantdigits and the rest is filled with zeros.

    Localized formats

    Because preferred formatting differs based on locale, there are a few tokens that can be used to format a moment based on its locale.

    There are upper and lower case variations on the same formats. The lowercase version is intended to be the shortened version of its uppercase counterpart.

    TimeLT8:30 PM
    Time with secondsLTS8:30:25 PM
    Month numeral, day of month, yearL09/04/1986
    l9/4/1986
    Month name, day of month, yearLLSeptember 4, 1986
    llSep 4, 1986
    Month name, day of month, year, timeLLLSeptember 4, 1986 8:30 PM
    lllSep 4, 1986 8:30 PM
    Month name, day of month, day of week, year, timeLLLLThursday, September 4, 1986 8:30 PM
    llllThu, Sep 4, 1986 8:30 PM

    are available in 2.0.0.LTS was added in 2.8.4.

    Escaping characters

    To escape characters in format strings, you can wrap the characters in square brackets.

    Similarities and differences with LDML

    Note: While these date formats are very similar to LDML date formats, there are a few minor differences regarding day of month, day of year, and day of week.

    Formatting speed

    To compare Moment.js formatting speed against other libraries, check out .

    Other tokens

    If you are more comfortable working with strftime instead of LDML-like parsing tokens, you can use Ben Oakes' plugin. .

    Default format

    Calling moment#format without a format will default to moment.defaultFormat. Out of the box, moment.defaultFormat is the ISO8601 format YYYY-MM-DDTHH:mm:ssZ.

    As of version 2.13.0, when in UTC mode, the default format is governed by moment.defaultFormatUtc which is in the format . This returns Z as the offset, instead of +00:00.

    In certain instances, a local timezone (such as Atlantic/Reykjavik) may have a zero offset, and will be considered to be UTC. In such cases, it may be useful to set moment.defaultFormat and moment.defaultFormatUtc to use the same formatting.