javascript - Convert Time to ISO to Angular Format -
i hitting api , json data.
i need change format json angular filter. format date getting is: 10/07/2014
, format of time is: 0745
.
i wrote angular function called converted date iso:
appcontroller.filter('datetoiso', function(){ return function(input) { input = new date(input).toisostring(); return input; };
});
then use angular filter render (date = 10/07/2014
:
{{outboundflights.departure_day | datetoiso | date: 'mediumdate'}}
and out puts this:oct 7, 2014
unfortunately, not work time (time = 0745
):
{{outboundflights.arrival_time | datetoiso | date: 'shorttime'}}
it outputs: 6:00pm
any idea why date works, time doesn't , possible solution?
i need convert time iso can use filter correctly.
so figure id it. had convert "normal" time out put custom filter:
appcontroller.filter('timetonormal', function(){ return function(input) { var splittime = input.split(""); var timeformat = splittime[0]+splittime[1]+":"+splittime[2]+splittime[3]; var newtime = new date("june 19, 1987 "+splittime[0]+splittime[1]+":"+splittime[2]+splittime[3]); return newtime; };});
1st split array, put colon :
between the 2nd & 3rd number, pass through normal date filter, html this:
{{outboundflights.arrival_time | timetonormal | date: 'shorttime'}}
this put acceptable format built-in "date" angular filter handle.
Comments
Post a Comment