Tharindu Senanayake Tharindu Senanayake - 1 year ago 56
AngularJS Question

Changing the return value of md-datepicker in Angular Material

I have started to use Angular-Material. When I use the datepicker the returning date value has not just the date. It has time and other information like below

2016-05-08T18:30:00.000Z


I just need the date with out the other information. Is there a way to do that

this is the code

<md-datepicker ng-model="data.Date" md-placeholder="Enter date"></md-datepicker>


controller code

app.controller('cntrlr',function($scope){
$scope.data = {};

});

Answer Source

I tried all the above things and due to my lack of knowledge in angular I failed miserably to succeed. The input I got was to my Web Api controller. What I did was I split the date value I'm getting from T.

string[] newdate = data.date.Split(T);

Then I assigned it to another string variable to get the split value which I wanted

string finaldate = newdate[0];

With this I got the date like "2016-05-17"

I'm not sure where this would help or this practice is acceptable. But I hope someone could benefit from this so I posted this. Thanks for the guys who help with the answers to this question too.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download