currentDateTimeString static method

String currentDateTimeString()

当前日期时间字符串 2021-06-20 15:32:41

Implementation

static String currentDateTimeString() {
  DateTime dateTime = DateTime.now();
  int year = dateTime.year;
  int month = dateTime.month;
  int day = dateTime.day;
  int hour = dateTime.hour;
  int minute = dateTime.minute;
  int second = dateTime.second;
  return format2Number(year.toString()) +
      "-" +
      format2Number(month.toString()) +
      "-" +
      format2Number(day.toString()) +
      " " +
      format2Number(hour.toString()) +
      ":" +
      format2Number(minute.toString()) +
      ":" +
      format2Number(second.toString());
}