void calucateDateRange() {
final currentDate = DateTime.now();
for (int i = 1; i <= 5; i++) {
final date = currentDate.subtract(Duration(days: i));
print(DateFormat.yMMMMd().format(date));
}
}
字符串
示例-显示下一个5天日期:-*
void calucateDateRange() {
final currentDate = DateTime.now();
for (int i = 1; i <= 5; i++) {
final date = currentDate.add(Duration(days: i));
print(DateFormat.yMMMMd().format(date));
}
}
2条答案
按热度按时间hsvhsicv1#
只需添加一个负的持续时间:
字符串
a5g8bdjr2#
字符串
型