OK, I thouhgt I got it right, but apparently I made a mess.
I have a script that pulls content for CURRENT month and PREVIOUS month from db.
Now, it only considers current month two weeks into the month. So if today is Feb. 1, it'll use January as CURRENT MONTH, but if it were Feb. 15 it'll make FEB a current month. To get the right content I need a MONTH ($checkMonth) and YEAR/B.
Everything worked fine until the year change and moths started going from 1 again and the previous month became 12. I am lost as of now trying to untangle my own mess. I'm sure it all can be simplified a lot! I'm at your mercy, here's what I've got:
// IMPORTANT!!! It'll use previous month is less then a 2 weeks of current month elapsed.
// gets current month
$currMonth = date('n',time());
$prevWeek = strtotime("-2 week");
// gets Month of previous week
$monthPrevWeek = date('n',$prevWeek);
$checkMonth = $currMonth;
// if this month is greater than last week's month number (i.e. last week was a different month), use last week's month to check events
if ($currMonth == 1) { //if January
$checkMonth = 12;
} else {
if ($currMonth > $monthPrevWeek) {
$checkMonth = $monthPrevWeek;
}
}
$current_month = date('F', strtotime($checkMonth . '/1'));
////// Logic to get stats based on the time of month <<--
//// Year logic -->>
$yearNow = date("Y");
if ($checkMonth == 12) {
$currentYear = ($yearNow -1);
} else {
$currentYear = $yearNow;
}
//// Year logic <<--