Answers for "how to subtract two dates in dart"

C#
0

how to subtract two dates in dart

int daysBetween(DateTime from, DateTime to) {
     from = DateTime(from.year, from.month, from.day);
     to = DateTime(to.year, to.month, to.day);
   return (to.difference(from).inHours / 24).round();
   //Using inHours instead of days b/c of daylight savings
  }

   //the birthday's date
   final birthday = DateTime(1967, 10, 12);
   final date2 = DateTime.now();
   final difference = daysBetween(birthday, date2);
Posted by: Guest on August-20-2021

Code answers related to "how to subtract two dates in dart"

C# Answers by Framework

Browse Popular Code Answers by Language