I have the following code to show the current date:
this.whatTime = Observable.interval(1000).map(x => new Date()).share();
And in my te
Use Angular's built-in DatePipe
:
{{ whatTime | async | date:'d/M/yy hh:mm:ss' }}
This converts Thu Sep 15 2016 18:15:17 GMT+0200 (Central Europe Daylight Time)
into your desired template: 15/9/16 06:15:17
.
You can read more about Angular's DatePipe
and its formats here and you can read more about Angular's pipes in general here.
Use Angular2 built in Date Pipe
{{whatTime | async | date:'yMdjm'}}
You should use this:
import moment from 'moment';
Then you should call it like that:
moment(timestamp).fromNow();
This will give you the current time.