Ext.define('school.view.basic.student.StudentDetailModel', { extend: 'school.view.core.form.FormPanelModel', alias: 'viewmodel.basic-student-studentdetail', formulas: { stu_birthday_change: { bind: '{stu_birthday}', get: function(v) { var val = new Date(v); var now = new Date(); var nYear = now.getFullYear(); var nMonth = now.getMonth() + 1; var nDay = now.getDate(); var vYear = val.getFullYear(); var vMonth = val.getMonth() + 1; var vDay = val.getDate(); var age = 0; if(nYear > vYear) { age = nYear - vYear; if((nMonth < vMonth) || (nMonth == vMonth && nDay < vDay)) { age--; } } this.set('stu_age', age); return v; } } } });