dependencies:
intl: ^0.17.0
import 'package:intl/intl.dart';
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
String string = dateFormat.format(DateTime.now()); //Converting DateTime object to String
DateTime dateTime = dateFormat.parse("2019-07-19 8:40:23"); //Converting String to DateTime object
DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm:ss").parse(savedDateString);
DateTime.parse("string date here");
String formatTimeOfDay(TimeOfDay tod) {
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, tod.hour, tod.minute);
final format = DateFormat.jm(); //"6:00 AM"
return format.format(dt);
}