So I have dates like this:
$scope.sample_time = "September 14th 2017, 1:00:00 pm";
And in my view, I want to only show the time like example 1:00 pm
.
Using angular-moment
, I tried something like {{ sample_time | amParse:'HH:mm a'}}
but I get 2017-09-14T06:00:00.000Z
.
Am I missing something here? Any help would be much appreciated.
Because
"September 14th 2017, 1:00:00 pm"
is not a default valid date, you need to parse it first, by the corresponding format you use (which is'MMMM Do YYYY, h:mm:ss a'
), then you got a valid date and can use amDateFormat to format it:amDatFormat:'HH:mm a'
a plunker: http://plnkr.co/edit/RocNLPq6uBlFnccLFB8N?p=preview