Oihana PHP Arango

aqlFieldDateTime.php

Table of Contents

Functions

aqlFieldDateTime()  : string
Generates an AQL key/value expression for a DateTime field.

Functions

aqlFieldDateTime()

Generates an AQL key/value expression for a DateTime field.

aqlFieldDateTime(string $key[, string $doc = AQL::DOC ][, string|null $keyName = null ][, string|null $format = null ]) : string

This helper builds a snippet suitable for inclusion in a RETURN { ... } block. It performs the following steps:

  1. Checks whether the specified document field contains a valid date string using IS_DATE_STRING().
  2. If valid, formats the date to the provided ISO 8601 pattern using DATE_FORMAT().
  3. If not valid, returns null.

This ensures that the resulting AQL object always contains a valid ISO-formatted date or null.

Example usage:

// PHP call
aqlFieldDateTime('createdAt');

// Generates
createdAt: IS_DATE_STRING(doc.createdAt) ? DATE_FORMAT(doc.createdAt, "%yyyy-%mm-%ddT%hh:%ii:%ssZ") : null
Parameters
$key : string

The key to use in the resulting AQL object (e.g. "createdAt").

$doc : string = AQL::DOC

The document alias or variable name (default: AQL::DOC).

$keyName : string|null = null

Optional field name in the document; if omitted, $key is used.

$format : string|null = null

Optional AQL date format pattern (default: ISO 8601 style "%yyyy-%mm-%ddT%hh:%ii:%ssZ").

Tags
since
1.0.0
author

Marc Alcaraz

Return values
string

AQL key/value expression string, e.g.: "createdAt: IS_DATE_STRING(doc.createdAt) ? DATE_FORMAT(doc.createdAt, "...") : null".

On this page

Search results