All contributions

ramsey/uuid

ramsey/uuid

A PHP library for generating universally unique identifiers (UUIDs).

Language
PHP
GitHub stars
12,642
Merged changes
1

What we changed

getDateTime() on a version 1 or 6 UUID with a timestamp just before the Unix epoch, such as 1969-12-31 23:59:59.999999, no longer throws an uncaught InvalidArgumentException. The conversion falls back to the backup converter instead.

What this work shows

  • Version 1 and 6 UUIDs
  • Floats and their string form in PHP
  • PHPUnit tests with data providers
  • PHPStan static analysis
What was broken

A time just before 1970 broke the conversion

PhpTimeConverter divided the count of 100-nanosecond intervals by the intervals per second and split the string form of the result on the decimal point. Near zero PHP renders such a number in scientific notation, such as -1.0E-6, so the fractional part became "0E-600" and Type\Integer threw. That is how getDateTime() ended for a UUID at 1969-12-31 23:59:59.999999.

How we fixed it

Scientific notation goes to the fallback converter

splitTime() now spots the E in the fractional part and returns an empty array, as the existing precision-loss guard does. convertTime() then falls back to GenericTimeConverter, which works on brick/math decimals.

#645

Merged change 1

  1. #645 Fix uncaught InvalidArgumentException in PhpTimeConverter for timestamps just before the Unix epoch Merged 13 November 2026

What it taught us

From an unclear exception we traced the cause to how numbers are written: PHP renders very small floats in scientific notation, and the code split that string on the decimal point. The fix is narrow on purpose and reuses the fallback path the method already had.

More about this technology: PHP

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.