Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript add business days to date

function add_bus_days(date, busDays) { // add business days to a date
                var wkdy = date.getDay(); // get weekday number
                var addDays = wkdy >= 3 ? (busDays + 2) : busDays; // if it's wednesday or later set add days to 5 instead of 3 to account for the weekend
                date.setDate(date.getDate() + addDays); // add days to current date
                return date
            }
// usage
var dt = new Date(); // get date
newDate = add_bus_days(dt, 3) // add 3 business days
Comment

PREVIOUS NEXT
Code Example
Javascript :: js make obj invisible 
Javascript :: add formdata to axios request in js 
Javascript :: jquery text replace 
Javascript :: js generate color from string 
Javascript :: js onchange paramteter sring 
Javascript :: stateprovider.js react 
Javascript :: java script cosinus grad 
Javascript :: regex char any quantity 
Javascript :: generate random 6 numbers in javascript 
Javascript :: file name without extension javascript 
Javascript :: javascript fisher yates shuffle mdn 
Javascript :: javascript is variable number or string 
Javascript :: how to square a value in javascript 
Javascript :: jquery get element by id from variable 
Javascript :: tab navigation react-native without title 
Javascript :: how to remove duplicates from array in javascript 
Javascript :: ignore node_modules 
Javascript :: javascript only allow show first few characters from a string 
Javascript :: chrome extension communication between popup and content script 
Javascript :: counting duplicates codewars javascript 
Javascript :: react query devtools 
Javascript :: async fetch api call 
Javascript :: string array to number array javascript 
Javascript :: sequelize logging insert 
Javascript :: odd even condition with ternary operator 
Javascript :: javascript get content between tags 
Javascript :: axios pass params 
Javascript :: javascript format number with commas 
Javascript :: https with express 
Javascript :: redirect with javascript to another page 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =