jquery - Filter array of objects by date -
i have array
0: object end: "11-24-2014" index: 0 start: "11-21-2014" 1: object end: "12-1-2014" index: 1 start: "11-28-2014
i need index of element current date between start , end.
any help?? thanks
loop array converting date strings dates , see if current date lies between them;
var index = check(arry); if (index >= 0) alert("found @ " + index); function check(arry) { var = new date(); now.sethours(0, 0, 0, 0); (var = 0; < arry.length; i++) if (now >= todate(arry[i].start) && <= todate(arry[i].end)) homecoming i; homecoming -1; function todate(str) { var d = str.split("-"); homecoming new date(d[2], d[0] - 1, d[1]); } }
jquery arrays date
No comments:
Post a Comment