Search code snippets, questions, articles...

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');
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.

Output

39
Was this helpful?
0 Comments