-3

How to convert JSON date from REST

/Date(1480525200000+0700)/

to string format dd/MM/yyyy

PROAMER
  • 9
  • 1
  • 5
  • 1
    Possible duplicate of [How do I format a Microsoft JSON date?](http://stackoverflow.com/questions/206384/how-do-i-format-a-microsoft-json-date) – silentsod Dec 12 '16 at 19:01
  • Note that I literally copy pasted your question title `Convert Json date /Date()/ to string` into a search engine and that dupe was in the first 5 results. – silentsod Dec 12 '16 at 19:02
  • thank you. But i don't understand how to use in ionic2 – PROAMER Dec 12 '16 at 19:37

1 Answers1

1

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.

Avnesh Shakya
  • 3,828
  • 2
  • 23
  • 31