Dates Compare

There is some form, or function in Ionic, that returns the address in days between two dates, example: I want to know the days between 2018-10-28 and 2018-11-05 = 9 days.

Thanks
Best regards

Exactly what you are looking for, and that library is pretty much everything you want or need for date-related stuff. Don’t listen to any of the people who will come in and recommend moment: it will needlessly bloat your app binary and requires an unwieldy dedicated object, whereas date-fns works cleanly with either JavaScript Dates or ISO8601 strings.

1 Like

Hi

You can use almost any library or function in javascript for Ionic.
Use javascript without fear.

Hello I was working fine with date-fns but I am creating a new project, I install the library and put this code
var differenceInDays = require(‘date-fns/difference_in_days’)
var result = differenceInDays(FechaHoy, Estatus.FechaVence );

but show me this error

error TS2580: Cannot find name ‘require’. Do you need to install type definitions for node? Try npm i @types/node.

I already install npm i @types/node`. but still doesnt work

Any Idea.?

In a new project, you should be able to use:

import * as differenceInDays from 'date-fns/difference_in_days';