DateTime toUtc()

Returns this DateTime value in the UTC time zone.

Returns this if it is already in UTC. Otherwise this method is equivalent to:

new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch,
                                        isUtc: true)

Source

DateTime toUtc() {
  if (isUtc) return this;
  return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch,
                                                 isUtc: true);
}