php strtotime “last monday” if today is monday?

后端 未结 8 1745
攒了一身酷
攒了一身酷 2020-11-30 03:45

I want to use strtotime(\"last Monday\").

The thing is, if today IS MONDAY, what does it return? It seems to be returning the date for the monday of la

8条回答
  •  自闭症患者
    2020-11-30 04:20

    How can I make it return today's date in that case?

    pseudocode:

    if (today == monday)
        return today;
    else
        return strtotime(...);
    

    Btw, this trick also could work:

    strtotime('last monday', strtotime('tomorrow'));
    

提交回复
热议问题