AngularJS/javascript converting a date String to date object

后端 未结 4 1120
终归单人心
终归单人心 2020-12-09 15:56

Im stuck on a problem and would appreciate any help. I have read through lot of the discussions already but they dont seem to work for me.

//I have a date a         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 16:33

    try this

    html

    Hello, {{newDate | date:'MM/dd/yyyy'}}!

    JS

    var myApp = angular.module('myApp',[]);
    
    function MyCtrl($scope) {
        var collectionDate = '2002-04-26T09:00:00'; 
    
        $scope.newDate =new Date(collectionDate);
    }
    

    Demo

提交回复
热议问题