datetimeangulartypescriptionic2toisostring

Locale time on IONIC2 Datetime picker


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?


Solution

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

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

    Thanks to sebaferreras