Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #subtract #dates #dart
ADD COMMENT
Topic
Name
9+7 =