生まれた日から年齢を計算する

function getAge(dob){
  var dyr = -1;
  var dmo;
 
  if(dob){
    var tod = @Today();
     
    dyr = @Year(tod) - @Year(dob)
    dmo = @Month(tod) - @Month(dob)
    if( dmo < 0 || (dmo = 0 && @Day(tod) < @Day(dob) )) {
      dyr = dyr - 1;
    }
  }
  return @Text(@Integer(dyr));
}




JavaScript (Server)
katoman
August 19, 2015 at 3:08 PM
Rating
0





No comments yetLogin first to comment...