Oihana PHP Arango

dateTrunc.php

Table of Contents

Functions

dateTrunc()  : string
Truncates the given date to the specified unit and returns the modified ISO 8601 date string.

Functions

dateTrunc()

Truncates the given date to the specified unit and returns the modified ISO 8601 date string.

dateTrunc([string|int|null $date = null ][, string|null $unit = DateUnit::MONTH ]) : string

Constructs an AQL expression in the format:

DATE_TRUNC(date, unit)

where date can be a numeric timestamp or ISO 8601 string, and unit specifies the precision to truncate to.

Supported units (case-insensitive):

  • y, year, years
  • m, month, months (default)
  • d, day, days
  • h, hour, hours
  • i, minute, minutes
  • s, second, seconds
  • f, millisecond, milliseconds
Parameters
$date : string|int|null = null

The date to truncate. If null, the current timestamp (DATE_NOW()) is used.

$unit : string|null = DateUnit::MONTH

The time unit to truncate to (default: "month").

Tags
example
echo dateTrunc('2025-10-08T12:34:56Z', 'day');
// Produces: DATE_TRUNC("2025-10-08T12:34:56Z", "day")
see
https://docs.arangodb.com/stable/aql/functions/date/#date_trunc
since
1.0.0
author

Marc Alcaraz

Return values
string

The AQL expression returning the truncated ISO 8601 date string.

On this page

Search results