Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comparing dateTime value and string dateTime
Message
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Autre
Titre:
Comparing dateTime value and string dateTime
Divers
Thread ID:
01620449
Message ID:
01620449
Vues:
31
Hi everybody,

In the interface I have a dateTime picker object with the date set to be "2011-04-07 18:37:30.000" (apparently, it's a string date).

And I also have an object which has dateTime property which is set to be in this format
"2015-05-28T12:31:06.217"
(this is I see when I output it to the console).

I have this code
if ($scope.startDate!=null && $scope.filteredTransactions[i].dateTime < $scope.startDate)
                            {
                                $scope.filteredTransactions.splice(i,1); // remove that element
                                continue;
                            }

                            //window.console && console.log('i is ' + i + ' Transaction Date is ' + $scope.filteredTransactions[i].dateTime + ' endDate is ' + $scope.endDate);
                            if ($scope.endDate!=null && $scope.filteredTransactions[i].dateTime > $scope.endDate)
                            {
                                $scope.filteredTransactions.splice(i,1); // remove that element                                
                            }
and it doesn't seem to work correctly for the time portion of the date.

Do you know what should I do to be able to properly compare these two values?


Also, for both values angular.isDate function returns false but angular.isString returns true, so both are treated as strings, I think.
Thanks in advance.

I am thinking that I need to create date object of both of them (e.g. dateTime property and my range dates). new Date() of both seem to work, so that's what I'm going to try now.

UPDATE. It seems to work but I had to add replace('T',' ') to the dateTime object, otherwise it was automatically converted to UTC.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform