angularjs - How to calculate time from now in javascript? -


i'm code newbie forgive me if answer question obvious!

i'm collecting json data api , have value, expecteddatetime, i'd use calculate number of minutes , seconds now.

it has format: 2016-05-09t12:26:26

i've tried this:

 function applytimetovallingby(data) {         $scope.timetovallingby = 0;         $scope.timetovallingby2 = 0;         d = new date();         for(i=0;i<data.responsedata.buses.length;i++){             if(data.responsedata.buses[i].journeydirection === 2){                 if($scope.timetovallingby===0){                     $scope.timetovallingby=(d-data.responsedata.buses[i].expecteddatetime);                 }else if($scope.timetovallingby!=0&&$scope.timetovallingby2===0){                     $scope.timetovallingby2=d-data.responsedata.buses[i].expecteddatetime;                 }             }         }     } 

but doesn't work. i've tried find way convert new date() value similar format of expecteddatetime, can subtract, haven't been able to.

best regards,

kind of diff of time :

var date = new date('2016-05-09t12:26:26');  var = new date();  alert(" seconds : " + parseint( (now.gettime() - date.gettime())/1000 ) );

in way - d.gettime() - new date( data.responsedata.buses[i].expecteddatetime).gettime()


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -