我正在使用角度材料日期选择器。
<mat-form-field>
<input matInput [matDatepicker]="picker" formControlName="form_birthdate" name="form_birthdate" placeholder="Choose a date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
日期应为ISO_8601
格式。这可能吗?
答案 0 :(得分:1)
我认为您可以通过标准JS功能转换日期。
var event = new Date('05 October 2011 14:48 UTC');
console.log(event.toString());
// expected output: Wed Oct 05 2011 16:48:00 GMT+0200 (CEST)
// (note: your timezone may vary)
console.log(event.toISOString());
// expected output: 2011-10-05T14:48:00.000Z
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString