AngularJS: show time from datetime -
i using angular in web application. showing placed orders users following code. , works fine:
<div class="orderspresent" ng-cloak=""> <div class="roworders" style="margin-bottom:5px;" ng-controller="allorders" > <div class="col-md-3" ng-repeat= "o in orders | orderby:-o.orderid" ng-hide= "o.orderstatus=='done'" ng-hide="hidden" ng-class="{fade: startfade}"> <div class="sm-st clearfix"> <div class="sm-st-info"> <i class="fa fa-square"></i> <input type="checkbox" ng-true-value="{{o.orderid}}" ng-change="statechanged({{o.orderid}})" ng-model="status"/> </div> <span>{{o.customername}}</span> <p>{{o.orderdate | date:'h:mm'}}</p> <ul> <li ng-repeat= "details in o.details"> {{details.aantal}} x {{details.producttitle}} <div ng-if="details.extras"> +{{details.extras}} </div> </li> <p class="totalprice">{{gettotal()}} euro</p> </div> </div>
but each of these orders want show time got ordered. tried using {{o.orderdate | date:'h:mm'}}
doesn't seem anything... how can show example: 10:06 or 12:10?
json data
[{"orderid":49,"customerid":61,"orderdate":"2015-05-06 10:03:05","orderdeliverydate":"2015-05-06 10:30:05"}, ...]
looks string passing date filter not valid iso 8601 datetime string filter can't handle it. closest orderdate
strings applicable format yyyy-mm-ddthh:mmz
. can either make strings '2015-05-06t10:03:05'
or convert them date objects before passing template: new date('2015-05-06 10:03:05')
.
here little demo of difference: http://plnkr.co/edit/t2nk1qs4smvgpzesi3ec?p=preview
Comments
Post a Comment