SPHPlayground API
SPHPlayground
sphplayground sphplayground

Date and Time

BASIC INFORMATION:

Classes under this namespace make it possible to represent date/time information. A rich set of methods is supplied to modify and format date/time information as well.

The date and time information in the DateTimeImmutable is stored as a 64-bit number so all conceivably useful dates (including negative years) are supported. [1]

All features follow ISO 8601 standard. This standard provides a well-defined, method of representing calendar dates and times worldwide. [2]

Times, Dates and Datetimes

The DateTimeImmutable and related classes allow you represent date/time information. The objects can be created by passing in a string presentation of date/time information, or from the current system's time.[1]

Following group of interfaces Date, Time and DateTime define addditional getters and modifiers to native PHP datetimes. These interfaces are implemented as immutable versions that use PHP's DateTimeImmutable instance as date data source.

Times, Dates and Datetimes

The DateTimeImmutable and related classes allow you represent date/time information. The objects can be created by passing in a string presentation of date/time information, or from the current system's time.[1]

Time-related data

ISO 8601 uses the 24-hour clock system. Either the seconds, or the minutes and seconds, may be omitted from the basic or extended time formats for greater brevity but decreased precision. [2]

Playground defines time in Time interface with representation of DateTimeZone timezones. Plain immutable time without dates is implemented in ImmutableTime class.

ISO Weeks and Months

An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. The extra week is sometimes referred to as a leap week. [3]

A CalendarWeek implements a traversable seven day ISO week of a year.

Calendar units

CalendarUnit has two enumeration implementations. These Enumerations localize weekday and month names. Implemented calendar unit instances can translate its name to various language by using IntlDateFormatter.

The Weekday enumeration

Weekday enumeration is used to specify an association between a weekday name and a weekday number.

Synopsis
enum Weekday: int implements CalendarUnit
case Monday = 1
case Tuesday = 2
case Wednesday = 3
case Thursday = 4
case Friday = 5
case Saturday = 6
case Sunday = 7
public jsonSerialize():object
Returns the name or an abbreviation of the weekday
public abbreviation(?int $length = null, ?string $locale = null):string

The Month enumeration

Month enumeration is used to specify an association between month name and a month number.

Synopsis
enum Month: int implements CalendarUnit
case January = 1
case February = 2
case March = 3
case April = 4
case May = 5
case June = 6
case July = 7
case August = 8
case September = 9
case October = 10
case November = 11
case December = 12
public jsonSerialize():object
Returns the name or an abbreviation of the month
public abbreviation(?int $length = null, ?string $locale = null):string

A CalendarMonth implements a traversable ISO month of a year.

CalendarMonth weeks as CalendarWeek instances.

Date Intervals