Skip to content

Commit

Permalink
fix call to microtime (#1)
Browse files Browse the repository at this point in the history
the previous incantation would cast the `microtime()` output to `int` before multiplying, which only allowed for 1-second resolution (the last three digits of `$now` were always zero)

casting to `int` after multiplying allows the intended millisecond resolution
  • Loading branch information
cfreeh authored and robinvdvleuten committed Jun 17, 2017
1 parent 5eecf02 commit eb193b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Ulid.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private function __construct($time, $randomness)
*/
public static function generate()
{
$now = (int) microtime(true) * 1000;
$now = intval(microtime(true) * 1000);
$duplicateTime = $now === static::$lastGenTime;

$timeChars = '';
Expand Down

0 comments on commit eb193b9

Please sign in to comment.