How to convert JSON date from REST
/Date(1480525200000+0700)/
to string format dd/MM/yyyy
How to convert JSON date from REST
/Date(1480525200000+0700)/
to string format dd/MM/yyyy
You can create a custom pipe:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'myDate'
})
export class MyDatePipe implements PipeTransform {
transform(value: string): any {
return new Date(parseInt(value.substr(6)));
}
}
then use in a template like this:
<div> date: {{jsonDate | myDate | date:"dd/MM/yyyy"}}</div>
where jsonDate
is your /Date(1480525200000+0700)/
you can see above link mentioned by @silentsod.