Skip to content Skip to sidebar Skip to footer

Get Friday Dates Of Year In Javascript Using Jquery

I have a Field called Reporting date which should give me a list of Dates drop down with the list of Friday Reporting Dates. Format (YYYY-MM-DD W1) for a particular financial year.

Solution 1:

Please look into the below code written in java script.

<!DOCTYPE html><html><body><script>var x = newDate();
       //set the financial year starting date
        x.setFullYear(2013, 03, 01);

       //set the next financial year starting datevar y = newDate();
        y.setFullYear(2014, 03, 01);
        var j = 1;
        var count = 0;

      //getting the all fridays in a financial yearfor ( var i = 0; x<y; i += j) {
            if (x.getDay() == 5) {
                document.write("Date : " + x.getDate() + "/"
                        + (x.getMonth() + 1) + "<br>");
                x = newDate(x.getTime() + (7 * 24 * 60 * 60 * 1000));
                j = 7;
                count++;
            } else {
                j = 1;
                x = newDate(x.getTime() + (24 * 60 * 60 * 1000));
            }
        }
        document.write("total fridays : " + count + "<br>");
    </script></body></html>

This returns the all fridays which in a financial year. You can modify this specific to your requirement.

Post a Comment for "Get Friday Dates Of Year In Javascript Using Jquery"