Created
April 4, 2023 14:00
-
-
Save fell-lucas/712693f91199ca80d5c252f157e695ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final dt = DateTime.now().toLocal(); | |
final deviceTimezoneOffset = dt.timeZoneOffset; | |
final offsetHours = deviceTimezoneOffset.inHours.abs().toString().padLeft(2, '0'); | |
final offsetMinutes = deviceTimezoneOffset.inMinutes.remainder(60).abs().toString().padLeft(2, '0'); | |
final offsetSign = (deviceTimezoneOffset.isNegative) ? '-' : '+'; | |
final offsetString = '$offsetSign$offsetHours:$offsetMinutes'; | |
print(dt.toIso8601String().substring(0, 19) + offsetString); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment