Hi I am trying to get the start time as current date 12:00 AM as my fromTime
DateTime toTime= new DateTime.now();
DateTime fromTime= toTime.subtract(new Duration(days: 1));
By above I am getting fromTime value as curent time - 24hrs, but I want fromTime as current date 12 AM
output what I am getting is
2019-09-30 14:25:36.105 //toTime
2019-09-29 14:25:36.105 //fromTime
expected output:
2019-09-30 14:25:36
2019-09-30 00:00:00
help me out to get the above,Thanks.
Did you mean like this:
DateTime toTime= new DateTime.now();
DateTime fromTime= new DateTime(toTime.year, toTime.month, toTime.day);
print(toTime);
print(fromTime);
output:
2019-09-30 17:15:20.294
2019-09-30 00:00:00.000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With