1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > PHP获取今日 昨日 本周 上周 本月 上月 本季 上季 今年 去年

PHP获取今日 昨日 本周 上周 本月 上月 本季 上季 今年 去年

时间:2022-07-26 06:12:50

相关推荐

PHP获取今日 昨日 本周 上周 本月 上月 本季 上季 今年 去年

//今天开始

$beginToday = date('Y-m-d 00:00:00', time());

//今天结束

$endToday = date('Y-m-d 23:59:59', time());

//昨天开始

$beginYesterday = date('Y-m-d 00:00:00', strtotime(' -1 day'));

//昨天结束

$endYesterday = date('Y-m-d 23:59:59', strtotime(' -1 day'));

//本周开始,周一开始

$beginThisWeek = date('Y-m-d 00:00:00', strtotime('this week monday'));

//本周结束,周日结束

$endThisWeek = date('Y-m-d 23:59:59', strtotime('this week sunday'));

//上周开始,周一开始

$beginLastWeek = date('Y-m-d 00:00:00', strtotime('last week monday'));

//上周结束,周日结束

$endLastWeek = date('Y-m-d 23:59:59', strtotime('last week sunday'));

//本月开始

$beginThisMonth = date('Y-m-01 00:00:00');

//本月结束

$endThisMonth = date('Y-m-d 23:59:59', strtotime('Last day of this month'));

//上月开始

$beginLastMonth = date('Y-m-01 00:00:00', strtotime('last month'));

//上月结束

$endLastMonth = date('Y-m-d 23:59:59', strtotime('Last day of last month'));

//本季度开始

$beginThisSeason = date('Y-m-01 00:00:00', strtotime((1 - (date('n') % 3 == 0 ? 3 : date('n') % 3)) . ' month'));

//本季度结束

$endThisSeason = date('Y-m-d 23:59:59', strtotime('last day of' . (3 - (date('n') % 3 == 0 ? 3 : date('n') % 3)) . ' month'));

//上季度开始

$beginLastSeason = date('Y-m-01 00:00:00', strtotime((-2 - (date('n') % 3 == 0 ? 3 : date('n') % 3)) . ' month'));

//上季度结束

$endLastSeason = date('Y-m-d 23:59:59', strtotime('last day of' . (- (date('n') % 3 == 0 ? 3 : date('n') % 3)) . ' month'));

//本年度开始

$beginThisYear = date('Y-01-01 00:00:00');

//本年度结束

$endThisYear = date('Y-12-31 23:59:59');

//上年度开始

$beginLastYear = date('Y-01-01 00:00:00', strtotime('last year'));

//上年度结束

$endLastYear = date('Y-12-31 23:59:59', strtotime('last year'));

转载:/linz1230/p/11424994.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。