https://github.com/simplecomplex/php-time
DateTime extension providing more, simpler and safer methods
https://github.com/simplecomplex/php-time
Last synced: about 1 year ago
JSON representation
DateTime extension providing more, simpler and safer methods
- Host: GitHub
- URL: https://github.com/simplecomplex/php-time
- Owner: simplecomplex
- License: mit
- Created: 2020-06-19T14:13:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T16:03:42.000Z (almost 5 years ago)
- Last Synced: 2025-02-16T04:42:43.363Z (over 1 year ago)
- Language: PHP
- Size: 229 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# (PHP) Time
composer namespace: simplecomplex/**time**
- [Requirements](#Requirements)
- [License](#MIT-licensed)
### [Time](src/Time.php)
extends native \DateTime to fix shortcomings and defects, and provide more properties, getters and setters.
## Features
- enhanced timezone awareness
- diff which works correctly with non-UTC timezones
- safer formatting and modifying
- is stringable (sic!), to ISO-8601
- JSON serializes to string ISO-8601 with timezone marker
- freezable
- directly accessible time part properties
- more, simpler and safer getters and setters
## Related classes
### [TimeInterval](src/TimeInterval.php)
has the same properties as native `\DateInterval` plus **signed relatives and totals**, and works with non-UTC timezones.
#### Time::diffTime()
returns interval with actual differences.
#### Time::diffDstIgnorant()
returns an interval which ignores daylight saving time shift.
In everyday business you often don't want the difference between a date _outside_ daylight saving time (DST)
and a date _inside_ DST to be off by the DST offset.
That offset can be particularly nasty if either of the dates is _at_ or _close to_ midnight,
because then the _days_ difference may get 1 off.
### [TimeSpan](src/TimeSpan.php)
It's main feature is to check **overlap** vs. another TimeSpan.
### [TimeImmutable](src/TimeImmutable.php)
Is an immutable extending Time, not `\DateTimeImmutable`.
### [TimeLocal](src/TimeLocal.php)
Forces instances to be in local (default) timezone.
## Requirements
- PHP >=7.2 (64-bit)
### Development requirements
- [PHPUnit](https://github.com/sebastianbergmann/phpunit) ^8 || ^9
- [Jasny PHPUnit extension](https://github.com/jasny/phpunit-extension) ^0.2
### Suggestions
- [SimpleComplex Inspect](https://github.com/simplecomplex/inspect)
## MIT licensed
[License and copyright](https://github.com/simplecomplex/php-time/blob/master/LICENSE).
[Explained](https://tldrlegal.com/license/mit-license).