toTzString method

String toTzString(
  1. bool inUtc, [
  2. int? numChars
])

Converts this date-time to a string in either local or UTC time zone. If numChars is provided, the string will be truncated to that length.

The result carries no time zone marker - state the zone with timeZoneLabel where the value is displayed.

Implementation

String toTzString(bool inUtc, [int? numChars]) {
  final s = inUtc ? toUtc().toString() : toLocal().toString();
  return numChars == null ? s : s.substring(0, numChars);
}