I need to get the day of the month from a Date object but it seems that the getDay()
method returns the day of the week. Is there a function that returns the da
Use date_object
.getDate() to get the month day.
From the MDN docs link:
"Returns the day of the month for the specified date according to local time."
var date = new Date().getDate();
Try getDate() instead. Confusing naming, but that's life...
const date = new Date();
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();