I am making an app displaying the current system time but I want to get the time my page started running so I can calculate and display the time that my page is up and running. I am using angularjs and currently has no idea on how can I get this. I have my code on getting the current system time like this
Current time is:
<span my-current-time="format1"></span>
<span my-current-time="format"></span> :
<span my-current-time="format3"></span> :
<span my-current-time="format4"></span>
<span my-current-time="format5"></span>
with this script
$scope.format1 = 'M/d/yy ';
$scope.format = 'h';
$scope.format3 = 'mm';
$scope.format4 = 'ss';
$scope.format5 = 'a';
$scope.format2 = 'Z ';
and a directive like this
.directive("myCurrentTime", function(dateFilter) {
return function(scope, element, attrs) {
var format;
scope.$watch(attrs.myCurrentTime, function(value) {
format = value;
updateTime();
});
function updateTime() {
var dt = dateFilter(new Date(), format );
element.text(dt);
}
function updateLater() {
setTimeout(function() {
updateTime(); // update DOM
updateLater(); // schedule another update
}, 1000);
}
updateLater();
}
});
I just want to display the total hours my page is currently running