getTimestampLatest static method

int getTimestampLatest(
  1. bool phase,
  2. int day
)

phase : 是零点还是23:59:59

Implementation

static int getTimestampLatest(bool phase, int day) {
  String newHours;
  DateTime now = new DateTime.now();
  DateTime sixtyDaysFromNow = now.add(new Duration(days: day));
  String formattedDate = DateUtil.formatDate(sixtyDaysFromNow, format: 'yyyy-MM-dd');
  if (phase) {
    newHours = formattedDate + ' 00:00:00';
  } else {
    newHours = formattedDate + ' 23:59:59';
  }

  DateTime newDate = DateTime.parse(newHours);
  String newFormattedDate = DateUtil.formatDate(newDate, format: 'yyyy-MM-dd HH:mm:ss');
  int timeStamp = newDate.millisecondsSinceEpoch;
  // print('时间' + newFormattedDate);
  return timeStamp;
}