user3849687 user3849687 - 29 days ago 6x
AngularJS Question

Grouping by date but not time in angular

I'm building my first angular app.

I'm am returning some JSON data from an API using a factory service which includes football match fixtures.

I want to group by date but disregard the time. The JSON date string is in the format of "2016-06-10T19:00:00Z"

I've managed to use groupBy on my ng-repeat and this works fine - only problem is - it takes into account the time also so 2 games on the same day at different KO times will not be grouped.

My JSON object is something like this an I assign it to an array in my controller called fixtures.list:


and my angular template like this:

My controller:

function FixturesController (EurosService) {
var ctrl = this;
ctrl.list = [];
function getFixtures () {
.then( function (response) {
ctrl.list = response;

.controller('FixturesController', FixturesController)

Help appreciated on this. Whats the best way to do this? Thanks.


Related to this answer

You can add a mapping function to your groupby filter: | map: toLocaleDate | groupBy: 'date' whereas your mapping function would like this:

$scope.toLocaleDate = function(e) { =;
    return e;

This function converts your date into a date only string. The timepart will be stripped from your original object.