📜  使用时刻获取年龄 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:55.411000             🧑  作者: Mango

代码示例1
var a = moment();
var b = moment('{dem_pat_birthyear}', 'YYYY');  
var diff = a.diff(b, 'years'); // calculates patient's age in years
diff; // this prints out the age
//In this calculation {dem_pat_birthyear} 
//needs to be replaced with your variable name for birth year.