DEV Community

Kurapati Mahesh
Kurapati Mahesh

Posted on


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();
> 31 // days in August
Enter fullscreen mode Exit fullscreen mode

First day in each month can start from any day.

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

For more date utils, you can refer: DateUtils

Also, follow for updates:

Top comments (2)

dhanushnehru profile image
Dhanush N

A point to add is new Date() will take the browser time zone

urstrulyvishwak profile image
Kurapati Mahesh

True. We can have location based timezone support as well natively.

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.