Skip to content

Instantly share code, notes, and snippets.

@rrazor
Created May 23, 2019 14:24
Show Gist options
  • Save rrazor/b87b2c1c8833dc2609a560ebdd5a137a to your computer and use it in GitHub Desktop.
Save rrazor/b87b2c1c8833dc2609a560ebdd5a137a to your computer and use it in GitHub Desktop.
Test showing that time() can be earlier than \DateTime() despite later in execution order
<?php
for ($tries = 0; $tries < 500000; ++$tries) {
$first = (int)((new \DateTime('now'))->format('U'));
$second = \time();
if ($second < $first) {
die("The second time was earlier after $tries tries:\n"
. " First: $first\n"
. " Second: $second\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment