Answers for "how to get current date using javascript"

17

return current date in javascript

let today = new Date().toLocaleDateString()

console.log(today)
Posted by: Guest on March-01-2020
19

current date in javascript

const localDate = new Date();
const months = [
   "January",
   "February",
   "March",
   "April",
   "May",
   "June",
   "July",
   "August",
   "September",
   "October",
   "November",
   "December",
];

const days = [
   "Sunday",
   "Monday ",
   "Tuesday",
   "Wednesday",
   "Thursday",
   "Friday",
   "Saturday",
];
const currentDay = days[localDate.getDay()];

const currentDate = localDate.getDate();

const currentMonth = months[localDate.getMonth()];

const currentYear = localDate.getFullYear();

console.log(`${currentDay}, ${currentDate} ${currentMonth}, ${currentYear}`);
Posted by: Guest on February-10-2021
0

how to get current date in js

let today = new Date();
let month = today.getMonth() + 1;
month = month < 10 ? "0" + month : month;
let days = today.getDate() < 10 ? "0" + today.getDate() : today.getDate();

today = today.getFullYear() + "-" + month + "-" + days;

console.log(today);
Posted by: Guest on July-02-2021

Code answers related to "how to get current date using javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language