js入社時間による勤続年数の判断
11665 ワード
// js ;
// :4 3 4
//visitTime
var actualEntryTime = $("#actualEntryTime").val();
var aDate = actualEntryTime.split("-");
var vDate = visitTime.split("-");
// 0-11,
var NewADate = new Date(aDate[0], aDate[1] - 1, aDate[2]);
var NewVDate = new Date(vDate[0], vDate[1] - 1, vDate[2]);
var dif = NewVDate .getTime() - NewADate.getTime();
NewVDate .setTime(dif);
var year = NewVDate .getFullYear() - 1970;
var month = NewVDate .getMonth();
var day = NewVDate .getDate();
if(year< 0 || NewVDate .getTime()> NewADate .getTime()){
$("#actualEntryTimeStr").html(" !");
}else if(year> 0 && month == 0 && day==0 ){
$("#actualEntryTimeStr").html(year+" ");
}else if(year> 0 && month>0 && day>0 ){
$("#actualEntryTimeStr").html(year+" "+month+" "+day+" ");
}else if(year == 0 && month>0 && day>0 ){
$("#actualEntryTimeStr").html(month+" "+day+" ");
}else if(year == 0 && month>0 && day==0 ){
$("#actualEntryTimeStr").html(month+" ");
}else if(year == 0 && month==0 && day>=0 ){
$("#actualEntryTimeStr").html(day+" ");
}