php strtotime “last monday” if today is monday?

后端 未结 8 1750
攒了一身酷
攒了一身酷 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:26

    Depending on exactly what you're using it for, this may be useful. Since one second's ambiguity is OK for my requirements, I use:

    date( 'Y-m-d 23:59:59', strtotime( 'last sunday' ))
    

    to get midnight on the most recent Monday (or today if today IS Monday).

提交回复
热议问题