0

I need to know the first day-of-week in a given time period. The day of the week will change so it could be Sunday, Monday, Tuesday, Wednesday, Thursday, or Friday. For example: I need to find the first Monday between 2011-10-30 and 2011-12-11.

2
  • 1
    please point out why none of stackoverflow.com/search?q=first+day+of+week+php helped solve your question Commented Nov 20, 2011 at 10:48
  • I'm not always looking for the first day of the week. Commented Nov 20, 2011 at 14:01

1 Answer 1

1

Just a little math with the date('N') (day of the week) value:

$timestamp = strtotime('2011-11-08'); $weekday = date('N', $timestamp); if ($weekday > 1) { $timestamp = strtotime('+' . abs(8 - $weekday) . ' days', $timestamp); } echo date('D Y-m-d', $timestamp); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.