ds355020 2014-05-10 05:53
浏览 59
已采纳

从当前日期()开始日历周

I find functions which return the week number for a given date. But instead, I would like to get the date of the first day of the particular calendar week returned. This would either be date() itself, or anything between date()-1 and date()-7.

Purpose: my site shall return events of this week. Right now, I only show the the range date()+7, which is not correct.

Thanks & Regards, Marcus

  • 写回答

1条回答 默认 最新

  • doutao6330 2014-05-10 05:57
    关注

    Use strtotime() function like this:

    strtotime("next monday");
    strtotime("this sunday");
    strtotime("last sunday"); 
    

    In your case:

    strtotime("this monday");
    

    As a result you have timestamp.

    The second way is like this:

    $day = date('w');
    $week_start = date('m-d-Y', strtotime('-'.$day.' days'));
    $week_end = date('m-d-Y', strtotime('+'.(6-$day).' days'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗