Untitled
unknown
plain_text
2 years ago
415 B
16
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...