Skip to content

Instantly share code, notes, and snippets.

@zombie6888
Created March 7, 2023 15:48
Show Gist options
  • Save zombie6888/bc9be50b29b131b7b42d8810dd27f38e to your computer and use it in GitHub Desktop.
Save zombie6888/bc9be50b29b131b7b42d8810dd27f38e to your computer and use it in GitHub Desktop.
void main() {
final now = DateTime.now();
final offset = now.timeZoneOffset;
final negativeDuration = Duration(hours: -3);
final duration = negativeDuration;
print(offset.isNegative);
print(negativeDuration.isNegative);
final date = DateTime.parse('2023-03-07 10:00').subtract(duration);
final utcDate = date.toLocal().toLocal().copyWith(isUtc: true).toIso8601String();
print(utcDate);
print(DateTime.parse(utcDate).toLocal());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment