angular 4 中显示日期晚一个月

One month behind date show in angular 4

angular 4 中显示的日期晚了一个月
Primeng 日历添加 2018-04-30 并显示 {3/30/2018}

Html 文件:

<div class="col-md-8 noPadding">
        <p-calendar dataType="date" name="PublishDate" [ngModelOptions]="{utc: 
            'true'}" [ngModel]="resource.PublishDate | date:'yyyy-MM-dd'" 
            (ngModelChange)="resource.PublishDate = $event" showOtherMonths="true" 
            dateFormat="yy-mm-dd" [showIcon]="true"></p-calendar>
</div>

打字稿:

update() {
                this.loading = true;
                this.publishDate  = this.resource.PublishDate.getMonth() + '-' + this.resource.PublishDate.getDate() + '-' + this.resource.PublishDate.getFullYear();

               this.resource.PublishDate = this.publishDate
                let data = JSON.stringify(this.resource); 


                this.resourceService.putForm('Resource').subscribe((response: any) => {
                    detail: 'Resource is Updated' });
                }, (error: any) => {

                });
            }

ts:

this.publishDate = this.datePipe.transform(this.resource.PublishDate);

html:

<p-calendar dataType="date" name="PublishDate" [ngModelOptions]="{utc: 
    'true'}" [ngModel]="resource.PublishDate | date:'yyyy-MM-dd'"
       (ngModelChange)="resource.PublishDate = $event" showOtherMonths="true"
          dateFormat="yy-mm-dd" [showIcon]="true">
</p-calendar>

app.module.ts

providers: [
    DatePipe
]

通过使用 angular 日期管道,我的问题得到解决 谢谢你 https://angular.io/api/common/DatePipe