0

I have this function:

Code JS:

$( "#date_of_birth" ).blur(function() {
    if($('#date_of_birth').hasClass("valid"))
    {
        var str=$(this).val().split("/");
        var day_str=str[0];
        var month_str=str[1];
        var year_str=str[2];
        var calc= year_str + "-" + month_str + "-" + day_str;
        var birthDate = new Date(calc);
        var today = new Date();
        var age = today.getFullYear() - birthDate.getFullYear();
        var m = today.getMonth() - birthDate.getMonth();

        if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
            age--;
        }
        $('#age').val(age);

    }

});

Currently, the format to be introduced to make the calculation is as follows

23/09/1982

I want to be format

09/23/1992

Can you help me please change the code?

Thanks in advance!

Marius
  • 1,001
  • 2
  • 13
  • 22

0 Answers0