pauci / datetime
Enhanced DateTime, DateTimeImmutable and DateInterval objects
Installs: 28 587
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 2
Open Issues: 0
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.9
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
Suggests
- pauci/datetime-doctrine: Allows the use of pauci/datetime value objects as Doctrine field types.
- dev-master
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.6
- v0.3.5
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.1
- 0.2.0
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-feature/date-interval-interface
- dev-feature/php-8.2
- dev-feature/psr-20
- dev-feat/enforce-format
- dev-feature/clock
- dev-feature/modify-wont-return-false
- dev-feature/php-8-1
- dev-github-actions
- dev-feature/bump-dev-dependencies
This package is auto-updated.
Last update: 2024-12-18 16:29:44 UTC
README
Provides enhanced DateTime
and DateInterval
objects with clock abstraction
- based on
DateTimeImmutable
object (to discourage the use of mutable version) - provides
SystemClock
for production andFrozenClock
for testing - provides extra static factory methods:
now()
(uses clock),fromString()
,fromTimestamp()
,fromFloatTimestamp()
- implements
Stringable
andJsonSerializable
with implicit conversion to string (ISO 8601)
Examples
use Pauci\DateTime\DateTime; $now = $clock->now(); // or DateTime::setClock($clock); $now = DateTime::now(); echo $now; // 2016-05-20T14:30:54.345678+02:00 echo json_encode($now); // "2016-05-20T14:30:54.345678+02:00" echo DateTime::fromTimestamp(1512148033); // 2017-12-01T18:07:13+01:00 echo DateTime::fromFloatTimestamp(1512148033.000005); // 2017-12-01T18:07:13.000005+01:00 DateTime::setFormat('Y-m-d H:i:s'); echo $now; // 2016-05-20 14:30:54 echo json_encode($now); // "2016-05-20 14:30:54"