Integer to Date - Angular

2

I have a question, in PHP I can convert a whole number to date, in the following way:

echo date("Y-m-d H:i",'1544102153');

and return:

2018-12-06 14:15

How can I do this in Angular? I've tried with:

{{'1544102153' | date:'dd/MM/yyyy(EEE) - hh:mmaaa'}}

But it returns to me:

18/01/1970(Sun) - 06:03PM

Thanks for the help.

    
asked by Spyros Capetanopulos 12.12.2018 в 13:05
source

1 answer

2

Javascript (and therefore also in Typescript) works with milliseconds:

const d1 = new Date(1544102153);

console.log('Fecha:',d1);

const d2 = new Date(1544102153 *1000);

console.log('Fecha pasando de segundos a milisegundos', d2);

So what you have to do is multiply your number by 1000.

    
answered by 12.12.2018 в 15:25