flutter

Find number of days between two dates in Flutter or Dart

If you are using dates in your dart program and want to get the difference between them in terms of the number of days then you can use the methods explained in this post.

DateTime dateA = DateTime.parse('2021-08-19'); 
DateTime dateB = DateTime.parse('2021-09-27');

final numOfDays = dateB.difference(dateA).inDays;

print('$numOfDays');

Output

39
Was this helpful?