2017-04-30 6 views
-1

In dieser Zeile in meinem Code.Datum Parsing mit Zeitzone AngularJS

<span> {{messages.created_time}}</span> 

Dies ist die ouput

2017-04-29T12:46:49+0000 

Allerdings würde ich die ouput sein mag:

n minutes ago // if less than one hour following the user timezone 

22:46 // if more or equal than one hour following the user timezone 

SUN AT 22:46 // if more or equal than a day following the user timezone 

APRIL 2 AT 22:46 // if more or equal than a week following the user timezone 

I Winkel js verwenden. Danke

+0

müssen Sie einen Filter schreiben, der die verschiedenen Möglichkeiten berechnet. – Claies

Antwort

0

Dies sollte einfach mit moment.js getan werden. Verwenden Sie einfach einen Winkelfilter und wenden Sie Ihre benutzerdefinierte Logik an.

<span> {{messages.created_time | filterfn}}</span> 

function filterfn(time){ 
    // all custom logic for span text creation 
    return $moment(time); 
}