Home > Net >  Flutter : How to set the hours, minutes and seconds to 0 from today's date irrespective of the
Flutter : How to set the hours, minutes and seconds to 0 from today's date irrespective of the

Time:07-25

I am trying to implement something which requires the date to be set at 00:00:00 for the next day. For example :

DateTime? created_at = DateTime.now(); //lets say Jul 25 10:35:90

Now I want a variable start_date whose value should be Jul 26 00:00:00

How can I achieve this ?

Any help will be appreciated.

CodePudding user response:

You can do something like below

DateTime? now = DateTime.now(); //lets say Jul 25 10:35:90
var lastMidnight = DateTime(now.year, now.month,  now.day   1);

It return 2022-07-26 00:00:00.000

  • Related