1

I use the following pattern:

 {{ item.EVPDATA | date: "dd.mm.yyyy HH:mm" }}

Value item.EVPDATA is UNIX time 1566473370:

I get formatted data as:

 19.07.1970 07:07 

Why I get wrong data?

4 Answers 4

2

As your data is in unix time, so before passing it to Date pipe you need to convert it to Date timestamp (by *1000), below code should work -

{{ (item.EVPDATA * 1000) | date: "dd.MM.yyyy HH:MM"}}

Stackblitz Working Example

For more shorthand pipe values for Date you can refer -

Sign up to request clarification or add additional context in comments.

Comments

1

try: {{ item.EVPDATA | date: "dd.MM.yyyy HH:mm" }}

3 Comments

It still gives me 19.07.1970 07:07
It should return me Thu, 22 Aug 2019 11:29:30 GMT in format
you can use date: 'full', or date: "EEEE, MMMM d, y, h:mm:ss a zzzz"
0

Here are the docs for the DatePipe: https://angular.io/api/common/DatePipe

Have you tried this:

{{ item.EVPDATA * 1000 | date: 'EEEE, MMMM d, y, h:mm:ss a zzzz' }}

Comments

0

you can use custom pipe:

import { Pipe, PipeTransform } from "@angular/core";
@Pipe({
  name: "mypipe"
})
export class MyPipe  implements PipeTransform {
  transform(unix: any): string {
    const time = new Date(unix * 1000)
    return time.toString();
  }
}

{{ item.EVPDATA | mypipe }}

See the sample

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.