Ion-datetime showing not local time

Hi friends,
I used ion-datetime but the selector shows the UTC time. I need to show my local time.

<ion-datetime [(ngModel)]="data" displayFormat="DD/MM/YYYY HH:mm" class="data-box"></ion-datetime>

I set “data” variable in my constructor. The string is local time but I show the UTC format.

Example. The time in Italy is 23:51. I set = 03/07/2018 23:51 but when the input field will apear, I see 23:51

Support me please


Your post is confusing.

That sounds like you are seeing the time you want, no? ion-datetime doesn’t care about timezones; it just deals with ISO8601 strings, so if you want the time and date you described, you just say: = "2018-07-03T23:51";

@lsantaniello… use moment js plugin

//install using command

>npm i moment

import * as moment from 'moment'; = moment().format();
1 Like

The advice in the previous post will needlessly bloat your app binary significantly.

What is the alternative?

@rapropos is a big fan of date-fns so I guess that’s the alternative, feel free to correct me If im wrong :slight_smile:

I integrated moment. Can I use Pipe into my html file?

for example: {{ | moment:‘dd/MM HH:mm’}}

I receive error
{{[ERROR ->] | moment:‘dd/MM HH:mm’}}

@lsantaniello you can directly use date pipe, there is no moment pipe in ionic.

1 Like

Thanks guys

I create my custom Pipe

import { Pipe, PipeTransform } from '@angular/core';

import * as moment from 'moment';

  name: 'moment',
export class MomentPipe implements PipeTransform {

  transform(date, format) {
    return moment(date).format(format);


<p>{{ | moment:'HH:mm'}}</p>

Thanks for support

1 Like

@AaronSterling’s date pipes are a much better choice.

1 Like