Getting difference between two date

hi this forum really helps me lot of things in ionic

please educate me how to get the difference between two dates.i search already but none of it works. and then i figured out that the date output is using -
Ex: 03-02-2017 how to convert this to 03/02/2017 to get the difference between two dates easily or is their any ionic way for this problems

this is my code

<ion-input type="date " [(ngModel)]=“check_in” required>

    <ion-label text>Check-out</ion-label>
    <ion-input type="date" [(ngModel)]="check_out" required=""></ion-input>

I use this (and related functions)

1 Like

how to apply this in my ionic sir?

Use the ES2015 import.

import differenceInCalendarDays from ‘date-fns/difference_in_calendar_days’

this one sir give errors when importing in ionic. can you guide me further sir if you have spare time.

  1. Always give the error message if you want help. We can’t read your mind.
  2. Given that you typed so fast, I think I know what is going on. You need to use npm to install the date-fns library. So do that. Please don’t ask me any more questions until you read some documentation, thank you.