How To Learn
How To Learn

Reputation: 301

date format is giving different result in angularjs

 <div ng-repeat="n in ShoeDetails.txnList">  
 <div ng-if="n.statusNo == 21">  
 <p ng-bind="n.timeStamp | date:'MM/dd/yyyy'"></p>  
 </div>
 </div>  

i'm trying to update the date format using angularjs,but i'm getting a result like this /Date(1459418939990+0530)/,unable to understand what was this,any help appreciated

Upvotes: 1

Views: 33

Answers (1)

Kyle
Kyle

Reputation: 5557

Those are ticks. You need to parse and convert it to a date object.

Either do the below in the frontend using javascript, or do it in C#.

var myDate = "/Date(1459418939990+0530)/";
var regex = /-?\d+/;
var match = regex.exec(myDate);
var date = new Date(parseInt(match[0]));

Upvotes: 1

Related Questions