Javascript has many functions dealing with Date and different output formats
Get month
const currentMonth = new Date();
const month = currentMonth.getDate();
console.log(month);
// The current month in days
// The output: 27
Get week as a number
const getWeekNumber = new Date();
const day = getWeekNumber.getDay();
/*
Sunday - 0
Monday - 1
Tuesday - 2
Wednesday - 3
Thursday - 4
Friday - 5
Saturday - 6
*/
console.log(day);
// The output: 3
Get a current Year
const date = new Date();
const getFullYear = date.getFullYear();
console.log(getFullYear);
// The output: 2021
Sometimes need to format the time date to store it in database server you can use ISO format
YYYY-MM-DDTHH:mm:ss.sssZ
The timezone is always zero UTC offset by Z
const event = new Date();
console.log(event.toISOString());
// The output: 2021-01-27T15:29:09.096Z