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

Installs: 84

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/krocos/datetimems

1.0.0 2017-01-06 16:34 UTC

This package is not auto-updated.

Last update: 2025-10-12 02:22:29 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);