May 25 2011
Here is method in calculating age in javascript. Its pretty simple, based from a sample age calculation code written in php which you can find here http://www.bradino.com/php/calculate-age/
function calculate_age(yr, mon, day)
{
var d=new Date(Date.UTC(yr,mon-1,day,0,0,0)).getTime();
var d1=new Date().getTime();
return Math.floor((Math.round(d1 / 1000) - Math.round(d / 1000))/31556926);
}
Sample usage.
document.write(calculate_age(1956, 5, 24));
No Comments |


