dateToDB function

String? dateToDB(
  1. DateTime? date, {
  2. bool withTime = false,
})

Use withTime to return python datetime format

Implementation

String? dateToDB(DateTime? date, {bool withTime = false}) {
  if (date == null) {
    return null;
  }
  if (withTime) {
    return DateFormat('yyyy-MM-ddTHH:mm:ss.000').format(date);
  }
  return DateFormat('yyyy-MM-dd').format(date);
}