Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show time along with date using Angular Material Date Picker?

I have added angular material date picker control in my angular project. I have to show the time along with the date. Can anyone let me know how can I show time along with the date using angular material date picker control?

Thanks

like image 432
Rafaqat Ali Avatar asked Dec 08 '19 11:12

Rafaqat Ali


People also ask

How do I add time on date picker?

Display the current date and time in a date pickerClick the Data tab. In the Data type box, click Date and Time (dateTime). Click Format. In the Date and Time Format dialog box, in the Display the time like this list, click the option that you want, and then click OK.

Is there time picker in angular material?

The Angular Time Picker, also known as the Angular Material Time Picker is a lightweight and mobile-friendly component that allows end users to select a time value either from a pop-up time list or by entering the value directly in the text box.


1 Answers

You can build a custom component using the DateTime Component of the Angular MateriaL.

<h1 class="mat-title">Angular Material DatetimePicker</h1>
<form novalidate [formGroup]="form">
    <mat-form-field>
        <mat-placeholder>Start DateTime</mat-placeholder>
        <input matInput formControlName="startDate" [matDatetimepicker]="dts" required autocomplete="false">
        <mat-datetimepicker-toggle [for]="dts" matSuffix></mat-datetimepicker-toggle>
        <mat-datetimepicker #dts type="datetime" openOnFocus="true" timeInterval="5"></mat-datetimepicker>
    </mat-form-field>
</form>

STACKBLITZ DEMO

like image 83
Sajeetharan Avatar answered Oct 19 '22 01:10

Sajeetharan