How to get the current day in JavaScript

Getting the current day of the month is essential for date displays, calendar highlighting, and day-based calculations in web applications. As the creator of CoreUI, a widely used open-source UI library, I’ve implemented day extraction in numerous calendar components, dashboard widgets, and date picker interfaces. From my expertise, the most straightforward solution is to use the getDate() method which returns the day of the month. This method provides values from 1-31 and automatically handles different month lengths and leap years.

Use getDate() method to get the current day of the month (1-31).

const currentDay = new Date().getDate()

The getDate() method returns the day of the month as an integer from 1 to 31, depending on the specific month and year. Unlike getMonth() which is zero-based, getDate() uses standard numbering where the first day of any month is 1. This method automatically accounts for months with different lengths (28, 29, 30, or 31 days) and leap year variations in February. It’s perfect for highlighting today’s date in calendars or creating day-based conditional logic.

Best Practice Note:

This is the same approach we use in CoreUI components for calendar highlighting and day-based dashboard features. Don’t confuse getDate() (day of month) with getDay() (day of week) - they serve different purposes in date manipulation and display logic.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author