timeZoneFormatted method

String timeZoneFormatted([
  1. bool seperateWithColon = true
])

Returns timezone:

-06:00 => GMT-6

+13:00 => GMT+13

You can disable seperateWithColon.

-0730 => GMT-7:30

+1300 => GMT+13

Implementation

String timeZoneFormatted([bool seperateWithColon = true]) {
  final int inMinutes = timeZoneOffset.abs().inMinutes;

  final int hours = inMinutes ~/ 60;
  final int minutes = inMinutes - (hours * 60);

  return (timeZoneOffset.isNegative ? "-" : "+") +
      hours.toString().padLeft(2, '0') +
      (seperateWithColon ? ":" : "") +
      minutes.toString().padLeft(2, '0');
}