<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular-animate.js"></script>
<style>
</style>
<script>
var app = angular.module("app", []);
app.controller('Ctrl', function ($scope) {
$scope.d = new Date();
$scope.d.setFullYear(1994, 11, 14); //jan[0-11] 2020 14th
$scope.calculateAge = function calculateAge(date) { // birthday is a date
var now=new Date();
var nowMonth = now.getUTCMonth() + 1; //months from 1-12
var nowDay = now.getUTCDate();
var nowYear = now.getUTCFullYear();
var myMonth_birth=date.getUTCMonth();
var myDay_birth = date.getUTCDate();
var myYear_birth = date.getUTCFullYear();
var birthAge = nowYear - myYear_birth - 1;//not ur age yet
if( nowMonth>=myMonth_birth) //means ur birth month is now or passed
if(nowDay >= myDay_birth)//check if the day is now or passed
birthAge += 1 ;
return birthAge;
}
});
</script>
</head>
<body ng-app="app" ng-controller='Ctrl'>
Birthdate: {{d|date}}<br/>
Age: {{calculateAge(d)}}<br/>
</body>
</html>
// Code goes here
/* Styles go here */