Locale time on IONIC2 Datetime picker

Samuel Fraga Mateos picture Samuel Fraga Mateos · Sep 21, 2016 · Viewed 7k times · Source

I'm working with IONIC2, Angular2 and Typescript. I have an Datetime working as follows:

page.html

<ion-datetime displayFormat="DD MMMM YYYY" pickerFormat="DD MMMM YYYY" [(ngModel)]="date"></ion-datetime>

page.ts

  date: string = new Date().toISOString();

The ion-datetime field shows time with an hour less, how can I display date on Datetime picker considering the timezone?

Answer

Samuel Fraga Mateos picture Samuel Fraga Mateos · Sep 21, 2016

Reading this answer I solve my problem. Finally I use:

moment(new Date().toISOString()).locale('es').format();

Thanks to sebaferreras