大佬教程收集整理的这篇文章主要介绍了角度材料DatePicker:日期变为所选日期之前的一天,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<md-input-container fxFlex="33" class="birthday-container"> <input mdInput name="birthday" placeholder="Birthday" required [(ngModel)]="member.birthday" [mdDatepicker]="birthdayPicker"> <button mdSuffix [mdDatepickerToggle]="birthdayPicker"></button> </md-input-container> <md-datepicker #birthdayPicker></md-datepicker>
在app.module中,这是提供者:
{provide: DateAdapter,useClass: NativeDateAdapter}
而member.birthday是日期类型.
但是当JSON.Stringify(member.birthday)时,它变为所选日期的前一天.例如:
从日期选择器中选择2017-4-1,字符串化结果为2017-03-31T13:00:00.000Z.
在对JS Date对象进行字符串化时,我们会得到明确的格林威治时区时间,我们可以在https://time.is/GMT看到它.您可能期望看到的是使用当前时区格式化的时间表示.看看我的例子中的差异.
// get current time let date = new Date(); console.log('NATIVE JS DATE TIME',date.toString()); console.log('StriNGIFIED TIME',JSON.Stringify(datE)); console.log('FORMATTED TIME',`${date.getHours()}:${date.getminutes()}:${date.getSeconds()}`);
以上是大佬教程为你收集整理的角度材料DatePicker:日期变为所选日期之前的一天全部内容,希望文章能够帮你解决角度材料DatePicker:日期变为所选日期之前的一天所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。