Saturday, June 1, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  15] [ 7]  / answers: 1 / hits: 6747  / 5 Years ago, fri, august 2, 2019, 12:00:00

I have a problem with the handling of dates in angular 8.



I have an api rest with symfony4 (apiPlatform) and it returns the dates with this format



balanceDate: 2010-10-04T00:00:00+00:00


If I pass it to my template without the applied Date pipe it puts exactly the same text



2010-10-04T00:00:00+00:00


when I use the pipe as follows in angular



{‌{ balanceDate | date:'dd-MM-yyyy' }}


The date is represented with one day less
enter



I have been doing tests, I manually added the date to the pipe and I was deleting parts of the date



{‌{ '2010-10-04T00:00:00+00:00' | date:'dd-MM-yyyy' }} - Fail
{‌{ '2010-10-04' | date:'dd-MM-yyyy' }} - Correct
{‌{ '2010-10-04T00:00:00' | date:'dd-MM-yyyy' }} - Correct


So I deduced that this part of the date



+00:00


It is the cause of the problem



I honestly have no idea on which side I should work the date output, whether in Angular or in the symfony api rest.



I hope you can guide me to solve this problem



Thank you


More From » angular

 Answers
3

If you know that the date is set as a UTC value (+00:00 or Z for the timezone), you can add the timezone specifier to the date pipe:



date:'dd-MM-yyyy':'UTC'

[#6701] Thursday, August 1, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stacie

Total Points: 476
Total Questions: 92
Total Answers: 102

Location: Bosnia and Herzegovina
Member since Tue, Mar 29, 2022
2 Years ago
stacie questions
Fri, Jun 26, 20, 00:00, 4 Years ago
Thu, Jan 23, 20, 00:00, 4 Years ago
Fri, Aug 30, 19, 00:00, 5 Years ago
Mon, Jul 15, 19, 00:00, 5 Years ago
;