So, PHP apparently feels like being a moron today. Or maybe it's me. Or both.
function before($test,$bar) {
$test = date_create($test);
$bar = date_create($bar);
$diff = date_diff($bar,$test);
$diff = $diff->format('%r%a') * 1;
return $diff<0;
}
It refuses to accept that a date generated by the following means:
date('m-d-Y', strtotime($date));
...is anything but a BOOLEAN! If I output the result, it comes out as a string, but - with PHP pining to confound me - before() treats it like something that it isn't. There is NOTHING here that should convert it to a boolean. I can feed it a string directly, and it works fine. Give it a date from a piece of code specifically made for the very purpose, well, we can't have that 'cause...
Warning: date_diff() expects parameter ... to be DateTime, boolean given
I thought, "fine, I'll give you your parser's desire."
function before($test,$bar) {
$test = new DateTime(date('Y-m-d',strtotime($test)));
$bar = new DateTime(date('Y-m-d',strtotime($bar)));
$diff = $bar->diff($test);
$diff = $diff->format('%r%a') * 1;
return $diff<0;
}
No change in result whatsoever. I gave it what it wanted, or at least what it said it wanted (I think), and it still rejects me. Coding mimicking reality.
I'm not terribly comfortable with dates yet. I'm also not terribly comfortable yet with how PHP handles the time of year. Any advice? And maybe how to get this to work, too?
Edit
Running var_dump($test)
object(DateTime)#7 (3) {
["date"]=>
string(19) "1970-01-01 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Berlin"
}