简体   繁体   中英

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.

Example: today (10th) is a 3rd week of August, on 14th it will be a third week of September and also Sunday. How would I find 14th of September knowing the 10th of August?

You can use strtotime() . http://php.net/manual/en/function.strtotime.php

And relative date format. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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