Skip to content

Instantly share code, notes, and snippets.

@DevKhalyd
Created August 2, 2020 04:43
Show Gist options
  • Save DevKhalyd/d3735c1851a09fa76751a0f136fa6acf to your computer and use it in GitHub Desktop.
Save DevKhalyd/d3735c1851a09fa76751a0f136fa6acf to your computer and use it in GitHub Desktop.
Unix Time
List<int> getmillisecondsSinceEpochNowAndAfter() {
//Get this day
String value = DateTime.now().toString();
//Get the only the date
String prefix = value.substring(0, 10);
//Today from 0 hours
var today = DateTime.parse("$prefix 00:00:00Z");
//Tomorrow from 0 hours
var afterDay = today.add(Duration(days: 1));
return [today.millisecondsSinceEpoch, afterDay.millisecondsSinceEpoch];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment