You can use entension like this and also can add some more extension methods in separate file like dateTime_extensions.dart to make your work easy for future projects as well
file: **dateTime_extensions.dart;**
```
extension DateTimeExtension on DateTime {
DateTime setTimeOfDay(TimeOfDay time) {
return DateTime(this.year, this.month, this.day, time.hour, time.minute);
}
DateTime setTime(
{int hours = 0,
int minutes = 0,
int seconds = 0,
int milliSeconds = 0,
int microSeconds = 0}) {
return DateTime(this.year, this.month, this.day, hours, minutes, seconds,
milliSeconds, microSeconds);
}
DateTime clearTime() {
return DateTime(this.year, this.month, this.day, 0, 0, 0, 0, 0);
}
///..... add more methods/properties for your convenience
}
```
use it like this
```
import 'package:your_app/dateTime_extensions.dart';
date.clearTime(); //to clear timeSpan
date.setTime(); //also be used to clear time if you don't provide any parameters
date.setTime(hours: 16,minutes: 23,seconds: 24); // will set time to existing date eg. existing_date 16:23:24
date.setTimeOfDay(TimeOfDay(hour: 16, minute: 59));
```