瀧谷賢司
瀧谷賢司

Reputation: 105

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

here was wrong.

final anHourAgo = (new DateTime.now()) - Duration(minutes: Duration.minutesPerHour);

Upvotes: 4

Views: 1655

Answers (2)

瀧谷賢司
瀧谷賢司

Reputation: 105

It is resolved.

final anHourAgo = (new DateTime.now()).subtract(new Duration(minutes: Duration.minutesPerHour));

Upvotes: 3

anmol.majhail
anmol.majhail

Reputation: 51226

This should Work :

Text(TimeOfDay.fromDateTime(DateTime.now().subtract(Duration(hours: 1))).format(context)),

Upvotes: 2

Related Questions