API reference / Quittio \ Core \ Support
Date
final readonly class in quittio/core · implements JsonSerializable, Stringable
Quittio\Core\Support\Date · Source
Calendar date without time of day.
Invoice dates are legal dates in the issuer's time zone. Storing them as year/month/day makes it impossible for a UTC conversion to shift them to the previous or next day.
Methods#
| Method | Description |
|---|---|
->__toString() | |
->addDays() | |
->compareTo() | |
->diffInDays() | |
->equals() | |
->format() | |
::fromFormat102() | Strict CII date in format 102 (YYYYMMDD), as used for incoming documents. |
::fromIsoDate() | Strict ISO 8601 calendar date (YYYY-MM-DD) with an optional time zone (Z, +01:00), as used by UBL (xs:date). The time zone does not shift the calendar date. |
->isAfter() | |
->isBefore() | |
->jsonSerialize() | |
::of() | |
::parse() | Accepts ISO dates (2026-10-03), the CII format 102 (20261003), date-time strings and DateTimeInterface instances. |
->toCarbon() | |
::today() | |
->toFormat102() | Date in UN/CEFACT format 102 (CCYYMMDD). |
->toIsoString() |
__toString()#
public function __toString(): string- Returns
string
addDays()#
public function addDays(int $days): self| Parameter | Type | Description |
|---|---|---|
$days | int |
- Returns
self
compareTo()#
public function compareTo(self $other): int| Parameter | Type | Description |
|---|---|---|
$other | self |
- Returns
int
diffInDays()#
public function diffInDays(self $other): int| Parameter | Type | Description |
|---|---|---|
$other | self |
- Returns
int
equals()#
public function equals(self $other): bool| Parameter | Type | Description |
|---|---|---|
$other | self |
- Returns
bool
format()#
public function format(string $format): string| Parameter | Type | Description |
|---|---|---|
$format | string |
- Returns
string
fromFormat102()#
public static function fromFormat102(string $value): selfStrict CII date in format 102 (YYYYMMDD), as used for incoming documents.
| Parameter | Type | Description |
|---|---|---|
$value | string |
- Returns
self- Throws
InvalidArgumentException
fromIsoDate()#
public static function fromIsoDate(string $value): selfStrict ISO 8601 calendar date (YYYY-MM-DD) with an optional time zone (Z, +01:00), as used by UBL (xs:date). The time zone does not shift the calendar date.
| Parameter | Type | Description |
|---|---|---|
$value | string |
- Returns
self- Throws
InvalidArgumentException
isAfter()#
public function isAfter(self $other): bool| Parameter | Type | Description |
|---|---|---|
$other | self |
- Returns
bool
isBefore()#
public function isBefore(self $other): bool| Parameter | Type | Description |
|---|---|---|
$other | self |
- Returns
bool
jsonSerialize()#
public function jsonSerialize(): string- Returns
string
of()#
public static function of(int $year, int $month, int $day): self| Parameter | Type | Description |
|---|---|---|
$year | int | |
$month | int | |
$day | int |
- Returns
self
parse()#
public static function parse(
self|DateTimeInterface|string $value,
DateTimeZone|string|null $timezone = null,
): selfAccepts ISO dates (2026-10-03), the CII format 102 (20261003), date-time strings and DateTimeInterface instances.
A DateTimeInterface is first converted into $timezone (if given), so that the calendar date matches the issuer's local date.
| Parameter | Type | Description |
|---|---|---|
$value | self|DateTimeInterface|string | |
$timezone | DateTimeZone|string|null = null |
- Returns
self
toCarbon()#
public function toCarbon(DateTimeZone|string|null $timezone = null): CarbonImmutable| Parameter | Type | Description |
|---|---|---|
$timezone | DateTimeZone|string|null = null |
- Returns
Carbon\CarbonImmutable
today()#
public static function today(DateTimeZone|string|null $timezone = null): self| Parameter | Type | Description |
|---|---|---|
$timezone | DateTimeZone|string|null = null |
- Returns
self
toFormat102()#
public function toFormat102(): stringDate in UN/CEFACT format 102 (CCYYMMDD).
- Returns
string
toIsoString()#
public function toIsoString(): string- Returns
string