I am trying to get the current day then getting the day before it, how can I get that date then convert it into a String?
DateTime now = new DateTime.now();
I am trying to get the current day then getting the day before it, how can I get that date then convert it into a String?
DateTime now = new DateTime.now();
You can do this by doing:
DateTime.now().subtract(Duration(days:1))
Source: https://api.flutter.dev/flutter/dart-core/DateTime-class.html
You can do this :
DateTime now = DateTime.now();
DateTime nowMinus1Day = now. subtract(const Duration(days: 1));
print(nowMinus1Day.toIso8601String());
you can try this
var now = DateTime.now();
var startDate= now.subtract(Duration(days: 1));
print(startDate);