Unix Epoch Two Way Data Binding for Material Datepicker

Viewed 380

I have a variable which holds a unix epoch timestamp as a number and I want to display this as a Material Datepicker. This should work with two way data binding, so the new picked date gets saved to the variable also as a unix epoch timestamp. I couldn't find how to use unix epoch time with the Material Datepicker, can someone help me with this? Or should I use one way data binding, format the variable as ISO date and listen for change events from the datapicker to convert it back to a unix epoch format?

<!-- Date -->
<mat-form-field>
   <input matInput [matDatepicker]="picker" placeholder="{{formatKey(item.key)}}" [(value)]="item.value">
   <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
   <mat-datepicker #picker></mat-datepicker>
</mat-form-field>

Thanks in advance for any help!

0 Answers
Related