Mr world wide
Mr world wide

Reputation: 4814

Angular js date filter "yyyy-mm-dd hh:mm:ss" to "MMM d, yyyy h mm"

I have a date like this

2019-02-15 16:01:18

and i am trying to show this in following format:

 Feb 2, 2019 4:01 PM

How can i achive this with date filter: here is what i tried:

{{ myDate | date:'MMM  d, yyyy hh:mm' }}

Upvotes: 1

Views: 1277

Answers (1)

MS_AU
MS_AU

Reputation: 412

From your comments it appears you are starting with a String, not a Date.

var dateString = "2019-02-15 16:01:18";
$scope.myDate = new Date(dateString);

Then you can use the date filter as you have tried:

{{ myDate | date:'MMM  d, yyyy hh:mm' }}

Upvotes: 1

Related Questions