izartu API

Format
in package

FinalYes

Present a timestamp for the view.

Lists show relative time ("2 days ago"); the exact moment goes in the element's title and datetime, shown on hover with no JavaScript.

Every method takes epoch seconds, as SQL's UNIX_TIMESTAMP returns them: nothing here parses a rendered date.

Table of Contents

Constants

UNITS  : mixed = [['name' => 'year', 'seconds' => 31536000], ['n...
Units for `ago()`, largest first. The length in seconds is both the threshold for using the unit and its divisor.

Methods

absolute()  : string
The full date and time, for the tooltip that backs the relative text.
ago()  : string
How long ago a moment was, in words.
iso()  : string
The moment as an ISO 8601 string, for a `<time datetime>` attribute.

Constants

UNITS

Units for `ago()`, largest first. The length in seconds is both the threshold for using the unit and its divisor.

private mixed UNITS = [['name' => 'year', 'seconds' => 31536000], ['name' => 'month', 'seconds' => 2592000], ['name' => 'week', 'seconds' => 604800], ['name' => 'day', 'seconds' => 86400], ['name' => 'hour', 'seconds' => 3600], ['name' => 'minute', 'seconds' => 60]]

Methods

absolute()

The full date and time, for the tooltip that backs the relative text.

public static absolute(int $timestamp) : string
Parameters
$timestamp : int

The moment, as epoch seconds.

Return values
string —

For example '1 August 2026 at 14:14'.

ago()

How long ago a moment was, in words.

public static ago(int $timestamp[, int|null $now = null ]) : string
Parameters
$timestamp : int

The moment, as epoch seconds.

$now : int|null = null

Reference point, as epoch seconds; the current time by default (the tests pass their own).

Return values
string —

For example 'just now', '5 minutes ago', '2 days ago'; a future moment (clock skew between app and database) reads 'just now'.

iso()

The moment as an ISO 8601 string, for a `<time datetime>` attribute.

public static iso(int $timestamp) : string
Parameters
$timestamp : int

The moment, as epoch seconds.

Return values
string —

For example '2026-08-01T14:14:41+00:00'.

On this page

Search results