2

I wanted to achieve this format: "Saturday, August 30, 2014"

I have this code in my view:

{{masterlist.created_date}}

And the result looks like this:

/DATE(1452842730000)/

What should I do in my controller or in the view? Thanks.

Jen143Me
  • 273
  • 7
  • 24
  • Refer [this answer](http://stackoverflow.com/questions/726334/asp-net-mvc-jsonresult-date-format) for an explanation of the behavior –  Feb 08 '16 at 08:27

2 Answers2

1

First of all you date should be in correct format

Use datefilter from angular {{masterlist.created_date | date:'fullDate'}}

Here is the doc

rkalita
  • 575
  • 4
  • 16
  • 1
    OP's input won't get parsed by date filter alone. Input still needs to be able to be parsed by `new Date()` – charlietfl Feb 08 '16 at 08:31
  • This is the format data from MVC controller: /Date(1452842730000)/ – Jen143Me Feb 08 '16 at 08:40
  • Of course you can cut your timestamp from this format and then filter him, but it'll be dirty code. You need to send a correct timestamp from your MVC controller (only timestamp 1452842730000) – rkalita Feb 08 '16 at 09:11
  • how will I do it? can you give me sample? – Jen143Me Feb 12 '16 at 15:16
0

Angular provides many filters, among them one is for date. It provides various format to format your date. Read about them here: date filter: angularjs

But filters can prove performance bottleneck, so its better to avoid them nd format your date on server side.

ashfaq.p
  • 5,379
  • 21
  • 35