如何测试值是否大于数组中的另一个值。 JavaScript的

时间:2014-07-15 09:20:17

标签: javascript arrays

我正在尝试在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 个答案:

答案 0 :(得分: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;
      }

    }