How to calculate (show, print) people (human) age using JavaScript?

How to calculate / show age using JavaScript:

<script>  
    var dob = new Date("06/24/2000");  
    //calculate month difference from current date in time  
    var month_diff = Date.now() - dob.getTime();  
      
    //convert the calculated difference in date format  
    var age_dt = new Date(month_diff);   
      
    //extract year from date      
    var year = age_dt.getUTCFullYear();  
      
    //now calculate the age of the user  
    var age = Math.abs(year - 1970);  
      
    //display the calculated age  
    document.write("Age of the date entered: " + age + " years");  
</script>  

Метаданные статьи

Идентификатор статьи:
61
Категория:
Дата добавления:
14.01.2022 08:51:29
Просмотры:
99
Рейтинг (Голоса):
(0)

Связанные статьи