jquery - filter json by timestamp year -


i have json array objects timestamp 2015.

json looks

    {   "data": [     { "name" : "blabla",       "address": testtest,       "timestampt": "2015-09-01t11:58:00.0000000z"       },       { "name" : "blabla2",       "address": testtest2,       "timestampt": "2015-10-01t11:58:00.0000000z"       },       { "name" : "blabla3",       "address": testtest3,       "timestampt": "2014-10-01t11:58:00.0000000z" ]} 

is there simple way search ex 2015 using jquery or js?

hope can me

first, must json right - quotes around values. then, use array.filter() :

var json2015 = json.data.filter(function(item) {     if (new date(item.timestampt).getfullyear() == 2015) return item; })       

demo -> http://jsfiddle.net/taddow3y/


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -