My previous question: how-to-find-current-day-no-in-month-in-php
Now I face another problem. Suppose I know that this monday
is the 4th monday of the current month.
Now how to check that this monday is also the last monday of the current month
?
exa:1 date: 27-01-2014
Using the code below, I get the name and number of a day:
day: monday day no :4th
This is the 4th monday of january and it is also the last monday of january. How to check that?
exa:2 date: 20-01-2014 day: monday day no :3rd
Here this monday is 3rd monday of january but not last monday of january.
So, in short, when I got a day number then how to check whether that the day number is last or not?
code:
$t=date('d-m-Y'); $dayName = strtolower(date("D",strtotime($t))); $dayNum = strtolower(date("d",strtotime($t))); $dayno = floor(($dayNum - 1) / 7) + 1
Advertisement
Answer
Just add 7 days (you still have a monday) to the date you have, and check if it’s in the same month.