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'));
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值