How to get the last day of the year using JavaScript

 

use the Date() constructor to create a date object and pass hardcoded month and day as we know december always has 31 days.

 

new Date('2022', 11, 31);

 

another example by passing date

var date = new Date(2022, 1,6);
var lastDayOfTheYear = new Date(date.getFullYear(), 12, 31);

Tags:

Share:

Related posts