JSFiddle - React, Tailwind, and code Playground

by Julien Etienne

HTML

<div ng-controller='TimeCtrl'>
    <p>{{ clock | date:'medium'}}</p>
</div>

JavaScript

function TimeCtrl($scope, $timeout) {
    $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);
}