Javascript: Get days & starting day in month

javascript:-get-days-&-starting-day-in-month

Each month in calendar will have max 28, 29, 30 and 31 days.

We can get using native JS date.


let days = new Date(2022, 8, 0).getDate();
console.log(days);
> 31 // days in August

First day in each month can start from any day.

let startingDay = new Date(2022, 8).getDay();
console.log(startingDay);
> 4 // represents Thursday

For more date utils, you can refer: DateUtils

Also, follow for updates: https://twitter.com/urstrulyvishwak

Total
13
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
5-vscode-extensions-every-web3-developer-should-install-

5 VSCode Extensions Every Web3 Developer should Install 🛠

Next Post
you-can-build-anything-with-these-6-characters:-[]{}!+

You can build anything with these 6 characters: []{}!+

Related Posts