Untitled
Anonymous
plain_text
08/28/2023 4:30 PM
556 B
29
Indexable
function convertDateFormat(inputDate) {
// Split the date string into [dd, mm, yyyy]
const parts = inputDate.split('/');
// Check if the date format is correct
if (parts.length !== 3) {
throw new Error('Invalid date format');
}
const [day, month, year] = parts;
// Return the date in yyyy-mm-dd format
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
}
Editor is loading...