toUtc method

DateTime toUtc()

Returns this DateTime value in the UTC time zone.

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

DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch,
                                    isUtc: true)

Implementation

DateTime toUtc() {
  if (isUtc) return this;
  return _withUtc(isUtc: true);
}