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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -