0

I want to work out which number week it is within a certain month.

For example

Days 1 - 7 = Week 1
Days 8 - 14 = Week 2
Days 15 - 21 = Week 3
Days 22 - 28 = Week 4

I know there are more days in some months than 28 but that doesn't matter i only want to work out 4 weeks worth.

Thanks in advance!

Exoon
  • 1,513
  • 4
  • 20
  • 35

1 Answers1

0

If you have a day in your hand; So basic but something like below:

if ($day > 0 && $day <8) {
$week = 1;
} else if ($day > 7 && $day <15) {
$week = 2;
} else if ($day > 14 && $day <22) {
$week = 3;
} else if ($day > 21 && $day <32) {
$week = 4;
}
Serhat Akay
  • 536
  • 3
  • 10