To help others - this is how I solved it with the help of the answer below using primeng calender, reactive forms in angular. Using (onSelect) callback specific to primeNg Calendarimport { DatePipe } from '@angular/common';<p-calendar #purchaseDateRef (onSelect)="handleSelect(purchaseDateRef)"></p-calendar>constructor( private datePipe: DatePipe) {}handleSelect(event: any) { // manipulate date object with help of DatePipe and setValue this.form.get('registrationFields.appliance.purchaseDate') .setValue(this.datePipe.transform(event.value, 'y.MM.dd') );}推荐答案您需要在组件中注入DatePipe,就像You need to inject DatePipe in your component, as构造函数(私有datePipe:DatePipe){} constructor( private datePipe: DatePipe){}您可以在组件中的任何位置使用转换功能than you can use wherever in the component the transform function const formattedDate = this.datePipe.transformer(dateValue,'build_in_date_format')const formattedDate = this.datePipe.transformer(dateValue, 'build_in_date_format')有许多内置格式,请参考官方文档 https://angular.io/api/common/DatePipe there are many build in formats, refer to the official documentation https://angular.io/api/common/DatePipe 这篇关于修剪日期格式PrimeNG日历-删除时间戳,角度反应形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-10 19:54