2014-07-15 2 views
0

나는 마지막 날짜를 가진 파일을 잡으려고 자바 스크립트 inorder에서 함수를 수행하려고한다. 내 problème 배열에서 발견 된 날짜 값을 비교하는 방법입니다. 나는이 유명한 질문, 그렇지 않은 경우 중복값이 배열의 다른 값보다 큰지 테스트하는 방법 javascript

//indentifiant[0] is an id that i caught in the file name 
//all_response is the content of the file 
var timeSusDat = stats.mtime + all_response; 

if (filesPerUser[identifiant[0]]) { 
    filesPerUser[identifiant[0]].push(timeSusDat); 
} else { 
    var testtab = [timeSusDat]; 
    filesPerUser[identifiant[0]] = testtab; 
}; 

function onlyLastDate(table) { 
    for (var d in table) { 
     id = table[d]; 
     for (var db in table[d]) { 
      data = table[d][db]; 
      date = data.split('/'); 
      var testDate = new Date(date[0]).getTime(); 

      console.log(testDate); 
     } 
    } 
} 
+1

아래의 코드를 시도했습니다. 여기에 대한 답변을보십시오 : [stackoverflow.com/questions/492994/compare-dates-with-javascript](http://stackoverflow.com/questions/492994/compare-dates-with-javascript) –

답변

0
function rangeDate(testDate){ 
     var dateStart = new Date($('#dateStart').val()).getTime(); 
     var dateEnd = new Date($('#dateEnd').val()).getTime(); 
     if (dateStart <= testDate && testDate <= dateEnd) { 
      date = true; 
      return date; 
     }else{ 
      date = false; 
      return date; 
     } 

    } 
관련 문제