danog / php-rtc-ntp
Pure-PHP NTP timestamp conversion for WebRTC. MadelineProto's PHP 8.2+ fork fixes unsigned 64-bit handling and integrates with the modular danog/php-rtc stack.
Fund package maintenance!
Requires
- php: ^8.2
Requires (Dev)
- phpunit/phpunit: ^11.3
- symfony/phpunit-bridge: 7.3.x-dev
README
The NetworkTimeProtocol class provides utility methods for working with NTP (Network Time Protocol) timestamps in PHP. It is part of the PHP WebRTC package and supports conversion between NTP timestamps and PHP DateTimeImmutable objects.
About this fork
This is the danog/php-rtc-ntp fork used by MadelineProto. It targets PHP 8.2+, removes the GMP dependency, and correctly handles unsigned NTP values above PHP_INT_MAX using pure-PHP arithmetic.
All internal Composer dependencies use their danog/php-rtc-* package names directly, so installing a component selects the maintained danog packages throughout the dependency graph.
Features
-
Convert current time to NTP timestamp (64-bit fixed-point)
-
Convert NTP timestamp to DateTimeImmutable
-
Accurate fractional second handling
-
Handles unsigned 64-bit fixed-point values without GMP
-
Fully UTC-compliant
Requirements
- PHP ≥ 8.2
Documentation
This package is part of the PHP WebRTC library. For complete documentation, examples, and API reference, visit:
Credits
Authors
-
Amin Yazdanpanah
- Website: aminyazdanpanah.com
- Email: github@aminyazdanpanah.com
-
Sana Moniri
- GtiHub: sanamoniri
Reporting Issues
Found a bug? Please report it on our issues.
License
BSD 3-Clause License. See LICENSE for details.