0

How can I change a date string to another date format in angularjs?
Lets say I get from DB a string in this format: "31/01/2015 2:21 PM".
I need to change it to "31-Jan-2015 14:21". Thanks.

RPichioli
  • 3,245
  • 2
  • 25
  • 29
monstro
  • 6,254
  • 10
  • 65
  • 111
  • Possible duplicate of [Changing date format javascript](http://stackoverflow.com/questions/34695685/changing-date-format-javascript) – Daniel Beck Sep 07 '16 at 20:00
  • (Or http://stackoverflow.com/questions/1056728/where-can-i-find-documentation-on-formatting-a-date-in-javascript may be more canonical. There are literally hundreds of near-identical questions on this subject.) – Daniel Beck Sep 07 '16 at 20:02

1 Answers1

0

I am assuming perhaps incorrectly that you want to display your date.. You can use the html time element:

<time [attr.datetime]="Post.PublishDate">
    {{Post.PublishDate | date: 'longDate' }}
</time>

Edit: per question substitute 'longDate' with your format string i.e. 'dd-MMM-yyyy'.