0

i'm trying to do a function in javascript inorder to catch a file that have the last date. My problème is how to compare the date value that is found in an array. I have tried the code below

//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);
        }
    }
}
thefourtheye
  • 233,700
  • 52
  • 457
  • 497
rodolphe
  • 33
  • 7
  • 1
    This is a famous question, if not a duplicate. Look here for answers: [stackoverflow.com/questions/492994/compare-dates-with-javascript](http://stackoverflow.com/questions/492994/compare-dates-with-javascript) – peter_the_oak Jul 15 '14 at 09:31

1 Answers1

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;
      }

    }
rodolphe
  • 33
  • 7