Flutter - How to find difference between two dates in years, months and days?

前端 未结 6 1222
梦毁少年i
梦毁少年i 2021-01-16 12:48

I\'m looking for a way to use DateTime to parse two dates, to show the difference. I want to have it on the format: \"X years, Y months, Z days\".

For J

6条回答
  •  离开以前
    2021-01-16 13:07

    DateTime a = DateTime(2015, 11, 29);
    DateTime b = DateTime(2007, 06, 27);
    int days = a.difference(b).inDays;
    

提交回复
热议问题