Oihana PHP Arango

timeUnit.php

Table of Contents

Functions

timeUnit()  : string
Returns a valid date/time unit string expression for use in AQL functions.

Functions

timeUnit()

Returns a valid date/time unit string expression for use in AQL functions.

timeUnit([string|null $unit = DateUnit::DAY ]) : string

This helper ensures the provided $unit is a valid time unit among: year(s), month(s), day(s), hour(s), minute(s), second(s), or millisecond(s). If the value is not recognized, it defaults to "day".

Example AQL usage:

DATE_ADD(date, 3, "day")
DATE_SUBTRACT(date, 2, "month")
Parameters
$unit : string|null = DateUnit::DAY

One of the following 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
Tags
example
echo timeUnit('day');      // "day"
echo timeUnit('month');    // "month"
echo timeUnit('unknown');  // "day"
see
https://docs.arangodb.com/stable/aql/functions/date/#date_add
since
1.0.0
author

Marc Alcaraz

Return values
string

The quoted valid time unit (e.g. "day").

On this page

Search results