Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
1.6 kB
1
Indexable
Never
<script>
jQuery(document).ready(function($) {
    
    function formatDate(date) {
        const [day, month, year] = date.split('/').map(Number);
        return `${dayz[day]} ${months[month]} deux mille ${dayz[year % 100]}`;
    }

   
    $('#input_1_26').on('change', function() {
        
        var selectedDate = $(this).val();
        
        
        var formattedDate = formatDate(selectedDate);
        
        
        console.log("La nouvelle date formatée est : " + formattedDate);

        
        $('#input_1_83').val(formattedDate);
    });
});


const dayz = {
    1: 'un',
    2: 'deux',
    3: 'trois',
    4: 'quatre',
    5: 'cinq',
    6: 'six',
    7: 'sept',
    8: 'huit',
    9: 'neuf',
    10: 'dix',
    11: 'onze',
    12: 'douze',
    13: 'treize',
    14: 'quatorze',
    15: 'quinze',
    16: 'seize',
    17: 'dix-sept',
    18: 'dix-huit',
    19: 'dix-neuf',
    20: 'vingt',
    21: 'vingt-et-un',
    22: 'vingt-deux',
    23: 'vingt-trois',
    24: 'vingt-quatre',
    25: 'vingt-cinq',
    26: 'vingt-six',
    27: 'vingt-sept',
    28: 'vingt-huit',
    29: 'vingt-neuf',
    30: 'trente',
    31: 'trente-et-un'
};

const months = {
    1: 'janvier',
    2: 'février',
    3: 'mars',
    4: 'avril',
    5: 'mai',
    6: 'juin',
    7: 'juillet',
    8: 'août',
    9: 'septembre',
    10: 'octobre',
    11: 'novembre',
    12: 'décembre'
};

function formatDate(date) {
    const [day, month, year] = date.split('/').map(Number);
    return `${dayz[day]} ${months[month]} deux mille ${dayz[year % 100]}`;
}
</script>
Leave a Comment