简体   繁体   English

查找每月第n周的一天(例如,找到下个月第二周的第二周的星期五,知道本月第二周的星期五)

[英]Find the day of every nth week of a month (e.g. find Friday of second week of next month knowing Friday the second week of this month)

How to find day of week of nth week of a month. 如何查找一个月的第n周的星期几。

Example: today (10th) is a 3rd week of August, on 14th it will be a third week of September and also Sunday. 示例:今天(10日)是8月的第3周,14日是9月的第3周,也是星期日。 How would I find 14th of September knowing the 10th of August? 我怎么会在9月14日知道8月10日呢?

You can use strtotime() . 您可以使用strtotime() http://php.net/manual/en/function.strtotime.php http://php.net/manual/en/function.strtotime.php

And relative date format. 和相对日期格式。 http://php.net/manual/en/datetime.formats.relative.php http://php.net/manual/en/datetime.formats.relative.php

date('Y-m-d', strtotime('first Sunday of September')); //2014-09-07
date('Y-m-d', strtotime('second Sunday of September')); //2014-09-14
date('Y-m-d', strtotime('third Sunday of September')); //2014-09-21

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM