change months name(output) from datetime calender

Question

I am creating a web app in which i am choosing a date from my Materialangular calender extender

<md-datepicker ng-model="mddate" ng-blur="dateformatechanged()" md-placeholder="Enter date"></md-datepicker>

and in my controler i am fetching the data like

   $scope.datemm = moment($scope.mddate).format('MM');
   $scope.dateyy = moment($scope.mddate).format('YYYY');
   console.log($scope.datemm);
   console.log($scope.dateyy);

in my $scope.datemm the month will be 01,02,03,04 as per the month i select but i want to fetch data like (january,february,march,april)

what i need to do in my controller to change the month output


Show source
| javascript   | angularjs   | datetime   2017-01-03 06:01 1 Answers

Answers to change months name(output) from datetime calender ( 1 )

  1. 2017-01-03 06:01

    Everything in your code is fine, but just change one line

    $scope.datemm = moment($scope.mddate).format('MM');
    

    to

    $scope.datemm = moment($scope.mddate).format('MMM');
    

    if you want to print(jan)

    and

    $scope.datemm = moment($scope.mddate).format('MMMM');
    

    if you want to print (january)

Leave a reply to - change months name(output) from datetime calender

◀ Go back