Created
March 7, 2014 07:03
-
-
Save coreymcmahon/9406656 to your computer and use it in GitHub Desktop.
DateTime example
This file contains hidden or 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
<?php | |
/* 00:00am (midnight) in Vietnam */ | |
$datetimeOne = new DateTime('2014-03-07 00:00:00+07:00'); | |
/* 04:00am in Australia */ | |
$datetimeTwo = new DateTime('2014-03-07 04:00:00+11:00'); | |
echo ($datetimeOne == $datetimeTwo) ? 'equal' : 'not equal'; | |
// prints 'equal' | |
/* just to prove it, let's check the unix timestamps: */ | |
echo $datetimeOne->getTimestamp(); | |
// prints '1394125200' | |
echo $datetimeTwo->getTimestamp(); | |
// prints '1394125200' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment