-1
The function is not wrong, the problem is that you are not taking into account the time zone (Time-zone).
This is returned in your JSON:
2020-08-04T07:38:33-04:00
Is being converted to:
2020-08-04 11:45:38.000Z
The "wrong" time is because of the time zone "04:00".
Parts of the date
JSON: 2020-08-04T07:38:33-04:00
Date: 2020-08-04 (yyyy-MM-dd)
Time: 11:45:38.000 (hh:mm:ss:zzz)
Spindle: 04:00
Adjustment
You can try using the toLocal()
in the moment of conversion
DateTime.parse(parsedJson['comeco']).toLocal()
Cool, I get it now, but how do I do it so he gets the right time zone?
– Jeff Henrique
@Jeffhenrique Try to do Datetime.parse(parsedJson['start']). toLocal()
– Matheus Ribeiro
Time zone would justify the difference in hours, but why does it have a difference in minutes too?
– Andre
@user140828 There is a whole calculation to be generated a date and time, hence you have to enter the classes to understand, this difference in minutes/ seconds if gives so.
– Matheus Ribeiro
@Matheus, can you give me a reference? I don’t think that your statement is correct.
– Andre
@user140828 What I said doesn’t really make sense, but in my tests here the minute/second were not changed as quoted in the question, only the time has changed.
– Matheus Ribeiro