I'm having trouble with the datetime
component in Ionic 2 beta 11. From what I gather in the Ionic API documentation, I should pass in a value from Date.toISOString. This works fine, except the date is displayed as UTC instead of the device's current timezone (PDT for my purposes). For example, the date appears as:
09/19/2016 8:46 PM
instead of the expected:
09/19/2016 1:46 PM
Here's my backing class:
export class TestPage {
private _date: Date = new Date();
public get date(): string {
return this._date.toISOString();
}
}
Any my template code for TestPage:
<ion-datetime
displayFormat="MM/DD/YYYY h:mm A"
pickerFormat="MM DD YYYY h mm A"
[(ngModel)]="date">
</ion-datetime>
I can work around this by applying the Date.getTimezoneOffset
to the date value first, but I'd rather avoid this since it seems that the framework should be accounting for timezone in the UI.
public get date(): string {
let n: number = this._date.getTime();
n -= (this._date.getTimezoneOffset() * 60 * 1000);
let d: string = new Date(n).toISOString();
return d;
}
Here's a Plunker I've created to demonstrate the issue: http://plnkr.co/edit/2iJRh1zM4pmwcNilWIcG?p=preview