I want to store the value of a datePicker in WixCOde

℡╲_俬逩灬. 提交于 2019-12-08 05:57:32

问题


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.


回答1:


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();


来源:https://stackoverflow.com/questions/49361758/i-want-to-store-the-value-of-a-datepicker-in-wixcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!