php 获得当天时间,并输出本周一到本周天

获得当天时间,并输出本周一到本周天。

// 获取当前日期
$today = date("Y-m-d");
 
// 获取本周第一天(周一)
$monday = date('Y-m-d', strtotime('monday this week'));
 
// 获取本周第二天(周二)
$tuesday = date('Y-m-d', strtotime('+1 day', strtotime($monday)));
 
// 获取本周第三天(周三)
$wednesday = date('Y-m-d', strtotime('+1 day', strtotime($tuesday)));
 
// 获取本周第四天(周四)
$thursday = date('Y-m-d', strtotime('+1 day', strtotime($wednesday)));
 
// 获取本周第五天(周五)
$friday = date('Y-m-d', strtotime('+1 day', strtotime($thursday)));
 
// 获取本周第六天(周六)
$saturday = date('Y-m-d', strtotime('+1 day', strtotime($friday)));
 
// 获取本周第七天(周日)
$sunday = date('Y-m-d', strtotime('+1 day', strtotime($saturday)));
IF(date('Y-m-d', strtotime('+1 day', strtotime($saturday)))==date("Y-m-d")){ECHO "一样1111111111111";}
// 输出结果
echo "本周周一日期:" . $monday . "\n";
echo "本周周二日期:" . $tuesday . "\n";
echo "本周周三日期:" . $wednesday . "\n";
echo "本周周四日期:" . $thursday . "\n";
echo "本周周五日期:" . $friday . "\n";
echo "本周周六日期:" . $saturday . "\n";
echo "本周周日日期:" . $sunday . "\n";

效果如下

在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值