Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
415 B
2
Indexable
Never
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')}`;
}