1

I want to compare two dates and times and get the event that occurred first. 1) 1652459529384 2) 2022-05-13T17:02:34Z

How can I change 2022-05-13T17:02:34Z to this millisecondsSinceEpoch ? Or How can I compare the two times in flutter?

Alex Maina
  • 443
  • 4
  • 10
  • Once you convert the string to a `DateTime` object, you can use its [`compareTo`](https://api.dart.dev/stable/dart-core/DateTime/compareTo.html), [`isBefore`](https://api.dart.dev/stable/dart-core/DateTime/isBefore.html), or [`isAfter`](https://api.dart.dev/stable/dart-core/DateTime/isAfter.html) methods to compare it to another `DateTime`, or use its [`millisecondsSinceEpoch`](https://api.dart.dev/stable/dart-core/DateTime/millisecondsSinceEpoch.html) getter. – jamesdlin May 13 '22 at 18:27
  • Thanks alot James, Your idea will help me much – Alex Maina May 16 '22 at 15:43

0 Answers0