0

I have this variable

public to: Moment;

and his value is (it is a Moment type variable, not a string)

 2019-12-31T23:59:59.999999999Z

in html when i use | date for change format angular change the value of date

{{to | date: 'dd-MM-yyyy HH:mm'}} 

the result is

01-01-2020 01:00

I don't undestand how prevent this behavior.

Pippi
  • 313
  • 1
  • 4
  • 18

2 Answers2

1

This looks like an error with timezones, try passing timezone as a parameter to angular's date pipe.

{{ value_expression | date [ : format [ : timezone [ : locale ] ] ] }}

and example would be

{{ to | date : "dd-MM-yyyy HH:mm", "en-GB", "GMT"}}
Sam
  • 1,736
  • 8
  • 15
0

Use

public to: Moment;
     to.toDate();

to convert it to a Date Object

dota2pro
  • 7,220
  • 7
  • 44
  • 79