Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dart datetime parse why I'm getting wrong value?

I’m trying to parse a DateTime from a response of a JSON object

print(DateTime.parse("2022-07-05T15:11:44+09:00"));

Getting output:

2022-07-05 06:11:44.000Z

Desired output:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

2022-07-05 03:11:44.000Z

How I will get the desired output?

>Solution :

Try calling .toLocal():

void main() {
    print(DateTime.parse('2022-07-05 06:11:44.000Z').toLocal());
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading