crawdidly // 1 day = 24 hours
// 24 * 60 * 60 = 86400 seconds
$dateDiff = ceil(abs($diff/86400));
Protip: not all days are 86400 seconds long.
This by itself is a red flag. It says "I'm trying to reimplement my own date-handling arithmetic" which is a bad sign when date/time libraries are already provided. PHP has things like the DateInterval class (which can be used to represent the difference between two DateTime objects). Are you trying to compare two different ways of doing something?
Since we don't know what
$a1['created'] contains we've got no idea what
$start_date should be, nor
$diff nor what it has to do with a 30-day interval; and especially no idea why any of that should be changing in whatever loop this is part of (since that isn't given either).
What we see:
- You get a date in some form from
$a1['created'] (the "start date")
- You get today's date (the "end date")
- You subtract the end date from the start date (the result will be negative unless the start date is after the end date)
- Ah, that's why the abs() is there; "throw stuff at the wall until something sticks". Divide that by 86400 and round up and hope that gives the right number of days
- Create a DateTime object from
- Add thirty days. Why thirty? I don't know. How does this relate to the day calculation in step 4? I don't know.
- If the number from step 4 is less than 30, print it and the date from step 6 in month-day-year format.
So ... what does all that achieve and what is it supposed to achieve?