How to calculate no of days between two days using datepicker

how to i calculate the No of days between selected two days using date picker?

The title fits perfectly here. Just because this is Ionic, it’s still JavaScript/TypeScript - meaning answers are also elsewhere than these forums :slight_smile: I don’t mean to be rude, sorry if it came off that way, but I just found the link a bit funny… heh

As long as you bound the inputs to a variable, plenty of the answers you’ll find on the link above should suffice. Throw it in a function returning the amount of days, and use that function in your html.

dateDifference() {
    // Some function you found via the link above...
    return days;
1 Like

i need how to calculate?
calculation code please…


The answer is on the link previously posted. Some of your questions have been asked many times, by many other people, and if you simply made a quick Google search you would already have your solution :slight_smile:

Using the link above, I found this. So using the brief example from the previous post, you could so something like this:

dateDifference() {
    var dropdt = new Date(this.firstdate);
    var pickdt = new Date(this.seconddate);
    return parseInt((dropdt - pickdt) / (24 * 3600 * 1000));

That took 2 minutes, and your post is ~45 minutes old. Do you see what I mean? :slight_smile: Try to stick to the flowchart below, when it comes to asking questions online

It will benefit you, and us. Again, I mean no disrespect! Hopefully what I wrote can be of use.

1 Like