作者:mobiledu2502898473 | 来源:互联网 | 2024-10-20 13:24
DateTimenowDateTime.now();DateTimetimeDateTime.parse(2018-12-31);if(now.isBefore(time)){Du
DateTime now = DateTime.now();
DateTime time = DateTime.parse('2018-12-31');
if (now.isBefore(time)) {
Duration duration = time.difference(now);
print(duration.inDays.toString());
}
Dart中,日期可通过isAfter或者isBefore判断日期的先后,通过difference()方法比较两个日期之间的差值