Saturday, September 10, 2022
HomeWordPress DevelopmentJavascript: Get days & beginning day in month

Javascript: Get days & beginning day in month


Every month in calendar could have max 28, 29, 30 and 31 days.

We are able to get utilizing native JS date.


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

Exit fullscreen mode

First day in every month can begin from any day.

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

Exit fullscreen mode

For extra date utils, you may refer: DateUtils

Additionally, comply with for updates: https://twitter.com/urstrulyvishwak



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments