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:
- Checks whether the specified document field contains a valid date string using
IS_DATE_STRING(). - If valid, formats the date to the provided ISO 8601 pattern using
DATE_FORMAT(). - 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,
$keyis used. - $format : string|null = null
-
Optional AQL date format pattern (default: ISO 8601 style
"%yyyy-%mm-%ddT%hh:%ii:%ssZ").
Tags
Return values
string —AQL key/value expression string, e.g.:
"createdAt: IS_DATE_STRING(doc.createdAt) ? DATE_FORMAT(doc.createdAt, "...") : null".