Ioinic 3 date format in view

Hello I want to format date value in view part but I’m getting this error “Please provide a valid ISO 8601 datetime format:” I have seen people are suggesting to use moment ,or date-fns.Can I use these library in view part? Or do you recommend an other solution without using external libraries?

 <ion-list  no-lines *ngFor="let item of CheckinList">
 <ion-card class="card">
  <ion-card-content no-lines text-wrap>
       <ion-datetime displayFormat="YYYY-MM-DDTHH:mmZ" [(ngModel)]="item.startDate"></ion-datetime>

in ur binding variable just use

public myDate = new Date().toISOString();
1 Like

thanks ,this is working too ,but I finally used pipe and moment library for formatting dates.
import { Pipe, PipeTransform } from ‘@angular/core’;
import moment from “moment”;

  name: 'custom',
export class CustomPipe implements PipeTransform {
  transform(value: Date, ...args) {
    return moment(value).format("YYYY/MM/DD, h:mm:ss a");

And the view is ;
<ion-label >Start Date: {{ item.startDate | custom }}</ion-label>

Fellow poster @AaronSterling`s date pipes are a better choice.

1 Like

yes ,your suggestion is better ,thanks !