getage() { var birthdays = new Date(this.birthday.replace(/-/g, "/")); var d = new Date(); var age = d.getFullYear() - birthdays.getFullYear() - (d.getMonth() < birthdays.getMonth() || (d.getMonth() == birthdays.getMonth() && d.getDat
方法一: SELECT TRUNC(months_between(sysdate, birth)/12) AS age from mytable 方法二: select TRUNC((to_char(sysdate, 'yyyyMMdd') - to_char(birth, 'yyyyMMdd')) / 10000) as age from mytable 注:sysdate 为系统日期时间,birth 为表中出生日期字段 作者:itmyhome
依据出生日期计算年龄 public class DateGetAge { public static int getAge(Date birthDay) throws Exception { Calendar cal = Calendar.getInstance(); if (cal.before(birthDay)) { throw new IllegalArgumentException( "The birthDay is before Now.It's unbelievable!"
public static String getAgeTxt(String birthTime,String beginTime,int level){ if(StringUtils.isBlank(birthTime)||StringUtils.isBlank(beginTime)){ System.out.println("参数中有空值!"); } int year = 0,month=0,day=0,hour=0; Date birthDate = getDateByString
function getAge(birth){ birth = birth.replace(/-/g,"/"); //把格式中的"-"替换为"/" birth = new Date(birth ); //替换后转为Date类型 var now = new Date(); //获取当前日期 var nowYear=now.getFullYear(); //当前日期的年份 var nowMonth=now.getMonth(); var nowDay
<script type="text/javascript"> //jquery页面加载完成后,根据后端的出生日期,计算年龄 $(function () { // 获得今天的时间 var date = new Date(); var birthday = '${userDetail.birthday}'; // alert(birthday); var startDate = new Date(birthday); var newDate = date.getTime()
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * Created by qing on 2017/3/28. */ public class AgeUtils { // 根据年月日计算年龄,birthTimeString:"1994-11-14" public static int getAgeFromBirthTime(String birthTimeS