Answers to $scope data convert to date format ( 3 )

  1. 2017-01-01 08:01

    Update: The input $ is actually an array of books. Pl refer authors comments.

    This is a rather crude way of doing it, but you can try something like this:

    <p data-ng-repeat="value in books">    
        {{value.take_time | date: 'shortTime'}} 
    $http.get("../api/book.php").then(function(response) {
          $ =;
          angular.forEach($, function(value, key) {
            var res = value.take_time.split(":");
            //Assuming time is in hh:mm:ss format
            var date = new Date();
            value.take_time = date;

    See a sample of it working here:

  2. 2017-01-01 08:01

    According to your comment you can try for "shortTime" date format

    'shortTime': equivalent to 'h:mm a' for en_US locale (e.g. 12:05 PM)

    for details--

  3. 2017-01-01 09:01

    Use Moment.js to convert time format


    or if you have array then

    angular.forEach($,function(value,key){value.take_time = moment(value.take_time).format('HH:mm')});

    below is link for that js

Leave a reply to - $scope data convert to date format

◀ Go back