JavaScript Получите текущую дату Yyyy-mm-DD
var todayDate = new Date().toISOString().slice(0, 10);
console.log(todayDate);
Run code snippet
Code Alchemy
var todayDate = new Date().toISOString().slice(0, 10);
console.log(todayDate);
Run code snippet
// yyyy-mm-dd
new Date().toISOString().slice(0, 10)
let today = new Date()
today.toISOString().split('T')[0]
// `date` is a `Date` object
const formatYmd = date => date.toISOString().slice(0, 10);
// Example
formatYmd(new Date()); // 2020-05-06
function convertDigitIn(str){
return str.split('/').reverse().join('/');
}
//yyyy-mm-dd to dd-mm-yyyy
const changeDateFormet=(date)=>{
const [year, month, day] = date.split('-');
return [day, month, year].join('-');
}
const newDate = changeDateFormet('2022-09-24')
console.log(newDate)