0

I need a way to round to the closest quarter hour.

Given time: 08:22 AM => Rounded to: 08:15 AM

Given time: 08:23 AM => Rounded to: 08:30 AM

I have this function to find the current time:

    $scope.clock = "loading clock..."; // initialise the time variable
    $scope.tickInterval = 1000 //ms

    var tick = function () {
        $scope.clock = Date.now() // get the current time
        $timeout(tick, $scope.tickInterval); // reset the timer
    }

    // Start the timer
    $timeout(tick, $scope.tickInterval);

I then need to round my clock to the nearest quarter hour.

user2456259
  • 157
  • 4
  • 13
  • 1
    Maybe have a look [here](http://stackoverflow.com/questions/4968250/how-to-round-time-to-the-nearest-quarter-hour-in-javascript). – John Oct 20 '14 at 17:58
  • Yes I saw that one. I was just wondering if there was an angular way to do the same thing. Thanks John. – user2456259 Oct 20 '14 at 17:58
  • Nope - not really something that angular handles. Use a third party library if you need better time handling in JS. Try momentjs.com – urban_raccoons Oct 20 '14 at 18:35

0 Answers0