age calculator javascript
function calculate_age(dob) {
var diff_ms = Date.now() - dob.getTime();
var age_dt = new Date(diff_ms);
return Math.abs(age_dt.getUTCFullYear() - 1970);
}
console.log(calculate_age(new Date(1982, 11, 4)));
console.log(calculate_age(new Date(1962, 1, 1)));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript program to calculate age</title>
</head>
<body>
</body>
</html>
Also in JavaScript:
- angular for loop
- how to lock device orientation using css and javascript
- ES6: Use class Syntax to Define a Constructor Function
- Mobx-react console warning related observer
- set iframe height and width by js
- what is .eslint.js in vue
- mongoose reference another model
- hide label chratjs
- npx for windows
- javascript json deserialize
- how to stop user from clicking outside alert box js
- find element in array underscore js
- moving a item fro index to another index, javascript
- javascript check if boolean is undefined
- js select element by css selector
- add parameter submit form javascript
- how to define state in react function
- "rbac" react redux navigation bar
- largest and smallest number in an array 1-100 javascript
- how to get the computer date and time jquery
- javascript clearinterval
- how to add redirec router in angular
- javascript redirect example
- js queryselector radio checked