Javascript first day of month and end day of month
const today = new Date();
let beginDate = new Date();
let endDate = new Date();
// fist date of montg
beginDate = new Date(
`${today.getFullYear()}-${today.getMonth() +
1}-01 00:00:00`
);
// end date of month
// set next Month first Date
endDate = new Date(
`${today.getFullYear()}-${today.getMonth() +
2}-01 :23:59:59`
);
// deducting 1 day
endDate.setDate(0);
留言
張貼留言