Skip to content

Instantly share code, notes, and snippets.

@Voles
Created April 25, 2013 12:41
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Voles/5459410 to your computer and use it in GitHub Desktop.
Save Voles/5459410 to your computer and use it in GitHub Desktop.
AngularJS daterange filter
RB.filter('daterange', function ()
{
return function(conversations, start_date, end_date)
{
var result = [];
// date filters
var start_date = (start_date && !isNaN(Date.parse(start_date))) ? Date.parse(start_date) : 0;
var end_date = (end_date && !isNaN(Date.parse(end_date))) ? Date.parse(end_date) : new Date().getTime();
// if the conversations are loaded
if (conversations && conversations.length > 0)
{
$.each(conversations, function (index, conversation)
{
var conversationDate = new Date(conversation.date_posted);
if (conversationDate >= start_date && conversationDate <= end_date)
{
result.push(conversation);
}
});
return result;
}
};
});
@Sigiller
Copy link

Thank you!

@kevinjstewart
Copy link

Thanks!

@LBSINDIA
Copy link

any jsfidle with this filter.. please upload an example..

@kalaie21
Copy link

please demo with Plunker for the functionality

@EricDosReis
Copy link

Thanks!

@achrefomrani
Copy link

Thanks you

@escuderomoyano
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment