Yeah, timezones can mess with your head.
I've tried - and had some success - with converting all times to your local timezone before comparing. The issue that you run into here is daylight savings time, which of course some areas honor and others don't. That having been said, if you instantiate a DateTimeZone() object set to the user's locale, you can instantiate a new DateTime() object using the user input and that DateTimeZone() object. Then set the timezone to GMT or your servers local timezone before doing the conversion.
private $_userTZ;
public function doCompare(){
$this->_userTZ = new DateTimeZone(/*Get the string from a database if possible*/);
$uDate = new DateTime($_GET['userDate'], $this->_userTZ);
$uDate->setTimeZone('UTC');
$compareDate = new DateTime(); //this will set the timezone to either the user or server timezone (I can't remember which, sorry...)
$compareDate->setTimeZone('UTC');
if($uDate >= $compareDate){
print("<p>Yup, {$uDate->format('Y-m-d')} is greater than or equal to {$compareDate->format('Y-m-d')}</p>");
}else{
print("<p>Nope. {$uDate->format('Y-m-d')} is not greater than or equal or {$compareDate->format('Y-m-d')}</p>");
}
}
Again, this is dodgy as DST is not taken into account, but has worked in the majority of situations I've used it. Of course, we also had the luxury of having all our customer's timezones stored in the customer table in the database, so that made life a bit easier as well.
Very much looking forward to other ideas on how to handle this...