The T stands for UTC standard time, while space denotes local time, so that's part of the normalization you have to do.
+++ Rick ---
>>You have to normalize those dates either both as strings or both as dates. Most date picker controls should have a way to convert an input date into an actual date.
>>
>>You can easily convert ISO dates (the string with the T in it) into dates by using:
>>
>>
>>var stringDate = "2015-05-28T12:31:06.217";
>>var date = new Date(stringDate);
>>
>>
>>I believe JavaScript is also smart enough to parse the date without the T and a space instead. I just tried this in the Node CLI and it new Date() converts either of your dates to real date values.
>>
>>However - I wonder why you're doing your date parsing and validation on the client. I think it's a better idea to leave that for server validation. Personally I try to deal with all date processing on the server and present dates in the UI only as strings.
>>
>>Otherwise if you do need to do lots of date manipulation and presentation via client code you might want to look at moment.js which provides solid date display and parsing functionality.
>>
>>+++ Rick ---
>
>The new Date(stringDate) worked fine, but it converted that date into 5 hours earlier date. So, I had to use replace('T',' ') in order for my dates to compare correctly.
>
>The whole point of this was to be able to filter my current list by date range. I didn't want to do another server trip for filtering (although I could have done that instead).
>
>So, my current code to apply filter (text based and date range based):
>
>
>$scope.applyFilter = function()
> {
> $scope.filteredTransactions = $scope.invoiceTransactionsObject.transactions.concat(); // make a copy of the initial array
> if ($scope.searchTerm.message)
> {
> $scope.filteredTransactions = $filter('filter')($scope.filteredTransactions, ({ message: $scope.searchTerm.message } || { item: $scope.searchTerm.message }));
> }
>
> if ($scope.startDate != null || $scope.endDate != null)
> {
> var initialLength = $scope.filteredTransactions.length;
>
> var startDate, endDate;
> var result = [];
> if ($scope.startDate)
> startDate = new Date($scope.startDate);
> else
> startDate = new Date(1900, 1, 1);
>
> if ($scope.endDate)
> endDate = new Date($scope.endDate);
> else
> endDate = new Date(3000, 1, 1);
>
> for (var i = 0; i < initialLength; i++)
> {
> var dt = new Date($scope.filteredTransactions[i].dateTime.replace('T',' '));
> if (dt >=startDate && dt <= endDate)
> {
> result.push($scope.filteredTransactions[i]);
> }
> }
>
> $scope.filteredTransactions = result;
> }
> $scope.filteredTotal = $scope.getTotal($scope.filteredTransactions, 'extension');
> }