1

Based on this Supplied Code,

$w.onReady(function () {
    //TODO: write your page related code here...
    const startFromDays = 4;
    const endAtMonths = 9;
    const today = new Date();
    let startDate = new Date(today);
    let endDate = new Date(today);

    startDate.setDate(startDate.getDate() + startFromDays);
    endDate.setMonth(endDate.getMonth() + endAtMonths);

    $w.onReady(function () {
        $w("#datePicker1").minDate = startDate;
        $w("#datePicker2").maxDate = endDate;
    });
});

I need help to find the difference between the endDate and the startDate and output it as Text. Knowing the fact that some start dates can be of the Eg: 26th of Feb and end Date can fall on 3rd March.

This Code is been run on Wixcode, where the dates are used as a Date-picker user input. Thank you.

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
usmanelvis
  • 11
  • 4
  • this is the site and how it looks like. I'm just trying to get the 2 dates and then get the number of days between them. https://infinityproduction7.wixsite.com/wixcoderv/wixcodepage – usmanelvis Mar 19 '18 at 18:46

1 Answers1

0

Start by getting the difference between the two dates using something like what is described in this post.

Then, use that number to populate a text field that you've added to your page.

So, assuming you have a datediff() function declared:

const diff = datediff(startDate, endDate);
$w("#text1").text = diff.toString();
Sam
  • 886
  • 1
  • 5
  • 8