I want to find the difference in days between two different datetimes in flutter.
in other words, i want to subtract two dates and get the difference between them
I found a way to do this in c# here. But unfortunately this doesn’t apply for flutter.
Any help is appreciated
>Solution :
You can use difference method of DateTime class to get the duration between two dates in dart.
DateTime date1 = new DateTime.now();
DateTime date2 = DateTime(2021, 1, 1);
print(date1.difference(date2).inDays); // Prints 356 days