heyr
heyr

Reputation: 5774

Date formatting using Moment library

              data() {
            return {

              date: Moment().format("llll"),
              console.log(date)
        }
       }

The type of format that I am trying to achieve is: Mon, 2 Jul, however through what I have implemented so far I get: Mon, Jul 2, 2018 5:08 PM. I am currently using the Moment date library https://momentjs.com/. however the one I am looking for is not listed in the documentation.

Upvotes: 0

Views: 44

Answers (2)

Matteo Pieroni
Matteo Pieroni

Reputation: 141

It is not clear why you are trying to format the date with "llll".

If it is for locale settings you can override the settings when instantiating locale (for example french) using an object:

moment.locale('fr', {
    longDateFormat : {
        LLLL : 'ddd, D MMM'
    }
}

And then return the date as

Moment().format("LLLL")

If you are not using a specific locale you can just go for what BenM wrote.

Upvotes: 0

BenM
BenM

Reputation: 53198

The formatting is fairly self-explanatory in the docs on Moment's website. It's easy to work out the correct for your example. Here's what you need:

moment().format('ddd, D MMM');

Upvotes: 3

Related Questions