I needed to create a simple function that calculated a person age using Javascript. The problem here is that the Date object in Javascript returns the time in milliseconds so we need to convert that to years, this is how.
var displayField;
var someonesBirthDate = someonesBirthDate;
var now = new Date();
var ms = now.valueOf() - someonesBirthDate.valueOf();
var minutes = ms / 1000 / 60;
var hours = minutes / 60;
var days = hours / 24;
var years = days/365;
displayField.DataValue = years;
Simple huh?














Recent Comments