If you want to compare, then you must use $currenttime, don't recreate $currenttime2 as that is a string, not an object. $currenttime = new DateTime(); creates a DateTime object with the current time as default.
0
This will set the time based on your date time settings in php.ini. Do a var_dump of $currenttime after creation to see what I mean. You may also use microtime(true); to obtain a unix timestamp, which can be converted using other functions.
date_default_timezone_set("America/New York");or whatever your timezone is. Other than that it should be fine. php.net/manual/en/function.date-default-timezone-set.phpnew DateTime();