<form>
<p-calendar [(ngModel)]="report.incidentTime" [showTime]="true" [ngModelOptions]="{standalone: true}" [maxDate]="maxDateValue"
(ngModelChange)="validateTime($event)"></p-calendar>
<button type="button" class="btn btn-primary ripple" (click)="saveReport()" >Save</button>
</form>
カレンダーを表示するためにprimeNgカレンダーを使用します。同じフィールドの異なる時間値
saveReport() {
console.log("Inside save");
this.validateFields();
let temp = this.report;
console.log("Time : "+this.report.incidentTime);
console.log("Object : "+JSON.stringify(this.report));
}
ここで、incidentTime:Date;は、atypeのDateです。
Time: Mon Oct 02 2017 09:34:39 GMT+0400 (Arabian Standard Time)
Object : {"incidentTime":"2017-10-02T05:34:39.000Z","reportingType":"I"}
ここで2つの出力が異なる時間を与えています。どうしてこれなの ? どうすればObjectでも同じ時刻を取得できます。代わりに4時間以下を与えるog。
GMTを使用している間に、ローカルタイムゾーンにあるのは同じ時刻です。時差が正しいようです – toskv
より後のタイムゾーンを追加して現在の時間を計算する必要はありますか? – user630209