tuupola / ulid
Universally Unique Lexicographically Sortable Identifier
Installs: 9 199
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.1|^8.0
- paragonie/random_compat: ^2.0
- tuupola/base32: ^1.0|^2.0
Requires (Dev)
- nyholm/nsa: ^1.1
- overtrue/phplint: ^1.1.2
- phpstan/phpstan: ^0.12.99
- phpunit/phpunit: ^7.0|^8.0|^9.0
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-10-21 16:53:41 UTC
README
This library implements the Universally Unique Lexicographically Sortable Identifier from Alizain Feerasta.
Install
Install with composer.
$ composer require tuupola/ulid
Usage
use Tuupola\Ulid; $ulid = new Ulid; print $ulid; /* 0001DD70YKYBES1P98DHWKTWZW */ //$ulid = ulid::fromString("0o5Fs0EELR0fUjHjbCnEtdUwQe3"); print $ulid->timestamp(); /* 1523811283 */ print bin2hex($ulid->payload()); /* f2dd90d9286c793d73fc */ $datetime = (new \DateTimeImmutable) ->setTimestamp($ulid->unixtime()) ->setTimeZone(new \DateTimeZone("UTC")); print $datetime->format("Y-m-d H:i:s"); /* 2018-04-15 16:54:43 */
Testing
You can run tests either manually or automatically on every code change. Automatic tests require entr to work.
$ composer test
$ brew install entr $ composer watch
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email tuupola@appelsiini.net instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.