I have an API that returns a users dob as a variable called dateOfBirth which comes from the API like so:
{
"dob": 1525219200
}
so now dateOfBirth is simply:
1525219200
How do I get the users age as an Int
from the above.
I have tried:
var dob = 1525219200;
var now = Date.now();
var age = new Date();
age = (dob - now).toUTCString()
document.write("dob: " + dob + "<br/>");
document.write("now: " + now + "<br/>");
document.write("age: " + age + "<br/>");
However, I am a junior dev and I think I am not understanding correctly what it is I am doing. Any and all help will be gratefully appreciated.
Here is a JSFIDDLE