Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6 material - how to get date and time from matDatepicker?

Tags:

angular

I have this piece of code in my html:

<mat-form-field>
    <input matInput [matDatepicker]="myDatepicker" placeholder="Choose a date" [(ngModel)]="model.value" name="value">
    <mat-datepicker-toggle matSuffix [for]="myDatepicker"></mat-datepicker-toggle>
    <mat-datepicker #myDatepicker></mat-datepicker>
</mat-form-field>

With this i'm able to get date with this format: YYY-MM-DDThh:mm:ss:millisZ.
Using matDatepicker i'm able to select the date but i need after the date selection to select the time too.
Is possible to achieve this result using matDatepicker ONLY?
Thanks

like image 353
Roberto Manfreda Avatar asked Jul 12 '18 14:07

Roberto Manfreda


1 Answers

No, as of now, it is not possible to choose time from matDatePicker. There is still an open issue on github regarding this feature.

Summary of the issue thread :

Alternatively you can use one of the following to have dateTimePicker for your project.

  1. MaterialTimeControl - Material Design with Angular Material, CDK, and Flex Layouts

  2. amazing-time-picker - Not built with Angular Material, but built to be compatible with it

  3. date-time-picker - Not fully Material Design, but built with the CDK

like image 165
Amit Chigadani Avatar answered Oct 02 '22 17:10

Amit Chigadani