if ($altime == "jinri") {
$t = time();
$first = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m", $t), date("d", $t), date("Y", $t))); // 当天开始时间
$last = date('Y-m-d H:i:s', mktime(23, 59, 59, date("m", $t), date("d", $t), date("Y", $t))); // 当天结束时间
}
if ($altime == "zuotian") {
$t = time();
$first = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d", $t) - 1, date("Y", $t)));
$last = date('Y-m-d H:i:s', mktime(23, 59, 59, date("m"), date("d", $t) - 1, date("Y", $t)));
}
if ($altime == "benzhou") {
$timestamp = time();
$first = date('Y-m-d H:i:s', strtotime("this week Monday", $timestamp));
$last = date('Y-m-d H:i:s', (strtotime(date('Y-m-d H:i:s', strtotime("this week Sunday", $timestamp))) + 24 * 3600 - 1));
}
if ($altime == "shangzhou") {
$timestamp = time();
$first = date('Y-m-d', strtotime("last week Monday", $timestamp));
$last = date('Y-m-d H:i:s', (strtotime(date('Y-m-d', strtotime("last week Sunday", $timestamp))) + 24 * 3600 - 1));
}
if ($altime == "benyue") {
$date = date("Y-m-d");
// 本月第一天
$first = date('Y-m-01 0:0:0', strtotime($date));
// 本月最后一天
$last = date('Y-m-d 23:59:59', strtotime("$first +1 month -1 day"));
}
if ($altime == "shangyue") {
$first = date('Y-m-d H:i:s', mktime(0, 0, 0, date('m') - 1, 1, date('Y')));
$last = date('Y-m-d H:i:s', mktime(23, 59, 59, date('m') - 1, date('t', $first), date('Y')));
}
if ($altime == "benji") {
$season = ceil(date('n') / 3);
$first = date('Y-m-d H:i:s', mktime(0, 0, 0, ($season - 1) * 3 + 1, 1, date('Y')));
$last = date('Y-m-d H:i:s', mktime(0, 0, 0, $season * 3, 1, date('Y')));
}
if($altime == "shangji") {
$season = ceil(date('n') / 3);
$first = date('Y-m-d H:i:s', mktime(0, 0, 0, ($season - 2) * 3 + 1, 1, date('Y')));
$last = date('Y-m-d H:i:s', mktime(23, 59, 59, ($season - 1) * 3, 1, date('Y')));
}
if ($altime == "bennian") {
$first = date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, date('Y')));
$last = date('Y-m-d H:i:s', mktime(23, 59, 59, 12, 31, date('Y')));
}
if ($altime == "shangnian") {
$year = date('Y') - 1;
$first = date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $year));
$last = date('Y-m-d H:i:s', mktime(23, 59, 59, 12, 31, $year));
}
今日:jinri
昨天:zuotian
本周:benzhou
上周:shangzhou
本月:benyue
上月:shangyue
本季度:benji
上季度;shangji
本年:bennian
上年:shangnian