Dart/Flutter Not converting local date time to UTC correctly
问题 I am building a flutter/firebase chat app and storing timestamps of messages in UTC. I am using this line of code to convert local time to UTC. 'time': DateTime.now().toUtc().toString(), When I tested this with two users one is in Virginia, US, and the other one in Sri Lanka. The timestamp of the user in Sri Lanka is converted correctly to UTC, but for user in Virginia time is correct but the date as of yesterday. Sri Lanka Time: 2020-06-21 20:50:48 UTC converted: 2020-06-21 15:20:48.027446Z