js get date day month year 1

js get date day month year

let dateObj = new Date();

let myDate = (dateObj.getUTCFullYear()) + "/" + (dateObj.getMonth() + 1)+ "/" + (dateObj.getUTCDate());

Here is what the above code is Doing:
1. We’re creating a new Date object.
2. We’re creating a new variable called myDate.
3. We’re assigning myDate to the current date.
4. We’re using the getUTCFullYear() method to get the current year.
5. We’re using the getMonth() method to get the current month.
6. We’re using the getUTCDate() method to get the current date.

Similar Posts