Created
February 16, 2020 03:59
-
-
Save ak2766/76b062ef050642cf1c9934031f499926 to your computer and use it in GitHub Desktop.
This file contains 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() { | |
print(getTimeInISO8601()); | |
} | |
String getTimeInISO8601() { | |
var ct = DateTime.now().toUtc(); | |
String year = ct.year.toString().padLeft(4,'0'); | |
String month = ct.month.toString().padLeft(2,'0'); | |
String day = ct.day.toString().padLeft(2,'0'); | |
String hour = ct.hour.toString().padLeft(2,'0'); | |
String min = ct.minute.toString().padLeft(2,'0'); | |
String sec = ct.second.toString().padLeft(2,'0'); | |
String timeUTC = '$year-$month-${day}T$hour:$min:${sec}Z'; | |
return timeUTC; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment