Answers for "how to set current date in js"

17

return current date in javascript

let today = new Date().toLocaleDateString()

console.log(today)
Posted by: Guest on March-01-2020
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 set current date in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language