lastMonthStart property
DateTime
lastMonthStart
上个月起始时刻,上月1日0时
Implementation
static DateTime get lastMonthStart {
final now = DateTime.now();
var year = now.year;
var month = now.month;
if (month == 1) {
// 如果当前是1月份,上月为去年12月份
year = year - 1;
month = 12;
} else {
// 否则上月等于本月-1
month = month - 1;
}
return DateTime(year, month, 1, 0, 0, 0);
}