user6882159
user6882159

Reputation:

change months name(output) from datetime calender

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

Upvotes: 1

Views: 35

Answers (1)

user6656728
user6656728

Reputation:

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)

Upvotes: 1

Related Questions