Download the PHP package dcarbone/gotime without Composer
On this page you can find all versions of the php package dcarbone/gotime. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download dcarbone/gotime
More information about dcarbone/gotime
Files in dcarbone/gotime
Download dcarbone/gotime
More information about dcarbone/gotime
Files in dcarbone/gotime
Vendor dcarbone
Package gotime
Short Description Golang-like time class(es) for PHP 8.2+
License MIT
Homepage https://github.com/dcarbone/gotime
Package gotime
Short Description Golang-like time class(es) for PHP 8.2+
License MIT
Homepage https://github.com/dcarbone/gotime
Please rate this library. Is it a good library?
Informations about the package gotime
gotime
Golang-inspired time helpers for PHP 8.2+.
Installation
Quick start
API overview
This package exposes a static facade class, DCarbone\Go\Time, plus several value objects under DCarbone\Go\Time\*.
Duration (DCarbone\Go\Time\Duration)
Duration stores elapsed time as a signed integer count of nanoseconds.
Common construction patterns:
Supported ParseDuration() units:
nsus,µs,μsmssmh
Key methods:
Nanoseconds(),Microseconds(),Milliseconds(),Seconds(),Minutes(),Hours()Truncate(Duration $m),Round(Duration $m)Compare(Duration $other)(-1,0,1)DateInterval()/IntervalSpec()__toString()(Go-like formatting, e.g.500ms,1h2m3.004s)jsonSerialize()(raw nanosecond integer)
Time (DCarbone\Go\Time\Time)
Time\Time extends \DateTime and adds Go-style helpers.
Primary constructors:
Comparison helpers:
Before(Time $t),After(Time $t),Equal(Time $t)BeforeDateTime(\DateTimeInterface $dt),AfterDateTime(...),EqualDateTime(...)
Unix helpers:
Unix()UnixNano()UnixNanoDuration()
Date/time part helpers:
Year(),Month(),Day(),Weekday()Hour(),Minute(),Second(),Nanosecond()IsZero()
Duration arithmetic:
AddDuration(Duration $d)SubDuration(Duration $d)
Static facade helpers (DCarbone\Go\Time)
- Constants:
Nanosecond,Microsecond,Millisecond,Second,Minute,Hour - Constructors and now/epoch:
New()Now()
- Duration operations:
ParseDuration(string $s)Duration(null|string|int|float|Duration|\DateInterval $input)CompareDuration(Duration $d1, Duration $d2)ZeroDuration()
- Relative time:
Since(Time\Time $t)SinceDateTime(\DateTimeInterface $dt)Until(Time\Time $t)UntilDateTime(\DateTimeInterface $dt)
Supporting value types
Time\Month(month ordinal/name helpers)Time\Weekday(weekday ordinal/name helpers)Time\IntervalSpec(intermediate duration-to-interval representation)Time\DateInterval(extends\DateInterval, including fractional seconds support)
Notes
- Precision in PHP runtime is microseconds; nanosecond APIs are represented as integer nanoseconds derived from microsecond resolution.
Duration(\DateInterval $input)converts years/months using average-hour constants, so calendar-month/year conversion is approximate.
Running tests
All versions of gotime with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.2
ext-json Version *
ext-json Version *
The package dcarbone/gotime contains the following files
Loading the files please wait ...