Format Date time in AngularJS

Format Date time in AngularJS

Asked on December 17, 2018 in AngularJs.
Add Comment


  • 4 Answer(s)

    Here is the simplest answer,

    Actually, v.Dt is not a Date() object.

    scope.v.Dt = Date.parse(scope.v.Dt);
    
    

    This is in our controller.

    Answered on December 17, 2018.
    Add Comment

    First of all we have to confirm that v.Dt is a proper Date object

    {{dt | date:'yyyy-MM-dd HH:mm:ss Z'}}
    
    

    or in case of dateFormat is defined as dateFormat = ‘yyyy-MM-dd HH:mm:ss Z’ in scope, use this code:

    {{dt | date:dateFormat }}
    
    
    Answered on December 17, 2018.
    Add Comment

    Simply we can get the solution by using this one line code,

    var today = $filter('date')(new Date(),'yyyy-MM-dd HH:mm:ss Z');
    
    

     

    Answered on December 17, 2018.
    Add Comment

    Format Date time in AngularJS

    scope.v.Dt = Date.parse(scope.v.Dt);
    Answered on February 22, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.