How do you get the first working day of the month in javascript?
How can I write a function that returns the date object of the following month's first workday (monday through friday) without using Moment.js? this code gets me the last businesss day of the month but i'd like to switch it to get me the first day of next month. Show
} asked Dec 17, 2018 at 21:04
3 You can generate a date for the first of the month, and if it's a Sunday add one day, if it's a Saturday add two days. You should also consider the name carefully. Not every Monday to Friday is a business day as some are holidays, and in many cultures and occupations the business week is not Monday to Friday.
answered Dec 18, 2018 at 0:58
RobGRobG 137k30 gold badges167 silver badges205 bronze badges If starting at an offset = 0 starts you at the last day of the month, then an offset of 1 will start you and the first day of the next month. And instead of working backwards with a offset--, you work forwards with an offset++.
answered Dec 17, 2018 at 21:42
Neil.WorkNeil.Work 9637 silver badges9 bronze badges 0 Date functions in JavaScript play a very important role in web applications. It not only provides date and month information, but also allows us to calculate and get results based on date related functions. I am going to show you how to get the first and last day of a given month using JavaScript functions. It’s a very common scenario. Let’s say I have a DatePicker control on my web page. Whenever a user selects a date from the DatePicker, it would call a JavaScript function that will get the first and last day (day in words) of the month. See this demo For the DatePicker, I would prefer using HTML5 input type date. This is a very useful control. However, I recommend you please check browser capabilities of this element. In-addition, check the below Related link to know more about the HTML5 input type date. 👉 Do you know you can get the first and last day of a month or date in SQL Server? Yes you can and its very simple. Check this post.
The Complete Code The onmouseout event of the input type element will call a user defined function getTheDay() written in the |