0

I am using Angular Material 2 date picker and want to format the date like - 'Sat 02-Mar-19'.

There is a guideline how to do that in Angular Material, as I am new to moment js and not familiar with it, so not able to get the expected format.

I tried to format the date by looking into the moment doc by changing the options provided by Angular Material but no luck.

What change I should do into the configuration provided by Angular material to get the date like - 'Sat 02-Mar-19'.

2
  • actually with material you can use "native" picker or "moment" picker. I found "moment" to be better cross-platforms Commented Feb 22, 2019 at 11:38
  • Any demo/plunker please ? Commented Feb 22, 2019 at 11:40

1 Answer 1

2

After spending a few hours on moment js document following material config work perfectly -

export const MY_FORMATS = {
  parse: {
    dateInput: 'ddd DD-MMM-YY',
  },
  display: {
    dateInput: 'ddd DD-MMM-YY'
  }
};

Hoping that this will save an hour for someone.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.