krocos / datetimems
There is no license information available for the latest version (1.0.0) of this package.
PHP DateTime class with the microseconds and conversion to a millisecond timestamp and vise versa
1.0.0
2017-01-06 16:34 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-12-21 21:36:46 UTC
README
Helps with conversions of JS-timestamps to \DateTime objects and to save a date and a time to database with microseconds (PHP and PostgreSQL (rof example) use microseconds internal, not milliseconds).
Creating
Creating \DateTime object with milliseconds:
use Krocos\DateTimeMs\DateTimeMs; $dateTimeWithMilliseconds = DateTimeMs::newDateTimeMs();
Converting
Converting to millisecond timestamp:
use Krocos\DateTimeMs\DateTimeMs; $msTimestamp = DateTimeMs::dateTimeToMsTimestamp($datetimeObject)
Converting from a millisecond timestamp to \DateTime object with milliseconds:
use Krocos\DateTimeMs\DateTimeMs; $msDatetime = DateTimeMs::msTimestampToDateTime($msTimestamp);