Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created March 7, 2014 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/9406656 to your computer and use it in GitHub Desktop.
Save coreymcmahon/9406656 to your computer and use it in GitHub Desktop.
DateTime example
<?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