Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Date format for material-datepicker in angular 2

I am new in 'angular2' and 'angular js material'. I am using material-datepicker in my project.

This is my the date picker code

<material-datepicker placeholder="Select Date" [(date)]="currentDate" name="currentDate" required></material-datepicker>

It will be display in browser as shown below.

enter image description here

My concern is date format issue. How to set the date format from 2017/04/27 to April 27 2017.

like image 494
Libin C Jacob Avatar asked Nov 07 '22 22:11

Libin C Jacob


1 Answers

You can use dateFormat option an specify MMMM DD YYYY tokens where:

  • MMMM is name month
  • DD is day of the month
  • YYYY is the year

as stated in the momentjs docs.

Your code will be like the following:

<material-datepicker [dateFormat]="'MMMM DD YYYY'" placeholder="Select Date" [(date)]="currentDate" name="currentDate" required></material-datepicker>
like image 51
VincenzoC Avatar answered Nov 14 '22 22:11

VincenzoC