All I need is to compare dates represented by string values in the format d.m.y (e.g. 15.07.11 for today).
strtotime unfortunatelly gives me wrong results (probably because of the format). I found a answer to my question (PHP strtotime incorrect conversion) but DateTime::CreateFromFormat is not available in my PHP version. I could not find strfptime but think the autor of the answer meant strptime. The result of strptime is a array. I was surprised that I can compare arrays but the compare result is not valid.
What would be the easiest way to compare dates in the given string format with PHP <= 5.1.6?
You could always pass the result of
strptimetomktimeand get a usable Unix timestamp which you can compare or feed to theDateTimeobjects.The only thing to watch for is that strptime gives the year as the number of years since 1900, and mk_time just takes a year number, so I added 1900 to it.