JavascriptSkills.com Uncategorized How to return the day of the week in Javascript

How to return the day of the week in Javascript

function getDay()
{

const date = new Date();
let day = date.getDay();
return day;

}

console.log(getDay())

// 0=Sunday
// 1=Monday
// 2=Tuesday
// 3=Wednesday
// 4=Thursday
// 5=Friday
// 6= Saturday

https://jsfiddle.net/azx1uhdv/1/

How to get today’s Date in Javascript Function Ex 11/2/2023

function getDate()
{

const date = new Date();

let day = date.getDate();
let month = date.getMonth() + 1;
let year = date.getFullYear();


currentDate = `${month}-${day}-${year}`;
return currentDate;

}



console.log(getDate())

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post