Created
July 31, 2013 14:32
-
-
Save EdwardIII/6122497 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function _compare_dates($utc_date_str, $date_obj){ | |
$date1 = DateTime::createFromFormat(DateTime::ISO8601, $utc_date_str); | |
$date2 = clone($date_obj); | |
print "--------------------------------------------------------------------------------\n"; | |
var_dump("Non-UTC Date1:"); | |
var_dump($date1); | |
var_dump("Non-UTC Date2:"); | |
var_dump($date2); | |
$utc = new DateTimeZone('UTC'); | |
$date1->setTimezone($utc); | |
$date2->setTimezone($utc); | |
$date1->setTime(0, 0, 0); | |
$date2->setTime(0, 0, 0); | |
var_dump("UTC Date1:"); | |
var_dump($date1); | |
var_dump("UTC Date2:"); | |
var_dump($date2); | |
var_dump("Are these the same?"); | |
var_dump(($date1 == $date2)); | |
print "--------------------------------------------------------------------------------\n\n"; | |
return ($date1 == $date2); | |
} |
Author
EdwardIII
commented
Jul 31, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment