javascript - How can I convert a date and time into a time only using angular-moment? -
so have dates this:
$scope.sample_time = "september 14th 2017, 1:00:00 pm";
and in view, want show time example 1:00 pm
.
using angular-moment
, tried {{ sample_time | amparse:'hh:mm a'}}
2017-09-14t06:00:00.000z
.
am missing here? appreciated.
because "september 14th 2017, 1:00:00 pm"
not default valid date, need parse first, corresponding format use (which 'mmmm yyyy, h:mm:ss a'
), got valid date , can use amdateformat format it: amdatformat:'hh:mm a'
{{ sample_time | amparse:'mmmm yyyy, h:mm:ss a' | amdateformat: 'h:mm s'}}
a plunker: http://plnkr.co/edit/rocnlpq6ublfncclfb8n?p=preview
Comments
Post a Comment