Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the previous date ( dd/mm/yy) in flutter

Tags:

date

flutter

I would like to display the previous date How do I do that?

i used this methode for display the date of today, i also want to display the previous date.

  static final DateTime now = DateTime.now();
  static final DateFormat formatter = DateFormat('dd-MM-yyyy');
  final String formatted = formatter.format(now);
like image 230
Fatima ELKADDOURI Avatar asked Nov 26 '25 07:11

Fatima ELKADDOURI


1 Answers

final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
final yesterday = DateTime(now.year, now.month, now.day - 1);
final tomorrow = DateTime(now.year, now.month, now.day + 1);
like image 124
Subair K Avatar answered Nov 28 '25 23:11

Subair K