Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get an hour ago on dart with flutter?

Tags:

flutter

dart

here was wrong.

final anHourAgo = (new DateTime.now()) - Duration(minutes: Duration.minutesPerHour);
like image 681
瀧谷賢司 Avatar asked Aug 31 '25 03:08

瀧谷賢司


2 Answers

It is resolved.

final anHourAgo = (new DateTime.now()).subtract(new Duration(minutes: Duration.minutesPerHour));
like image 182
瀧谷賢司 Avatar answered Sep 02 '25 18:09

瀧谷賢司


This should Work :

Text(TimeOfDay.fromDateTime(DateTime.now().subtract(Duration(hours: 1))).format(context)),
like image 25
anmol.majhail Avatar answered Sep 02 '25 18:09

anmol.majhail