posts = [{"content":"content1",
"created":"2013-12-27T14: 15: 27.747Z"},
{"content":"content2",
"created":"2013-12-27T14: 15: 02.956Z"}]
How to check posts[0]
and posts[1]
was created in the same day or not with Angularjs?
Angular doesn't really have a built in way to compare dates, but it can be done in conjunction with angular.
http://jsfiddle.net/TheSharpieOne/LxTGd/1/
This will compare if the day, month, and year are the same, determining if the 2 dates are on the same day (time is irrelevant).
$scope.sameDay = function(date1,date2){
return date1.substring(0,10) === date2.substring(0,10);
}
This functionality would ideally be made into some sort of directive. But this is just a basic example, a directive example can be made if required.