Reputation: 323
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.
Upvotes: 0
Views: 372
Reputation: 1861
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"}}
Upvotes: 1
Reputation: 7856
Use
public to: Moment;
to.toDate();
to convert it to a Date Object
Upvotes: 0