Oihana PHP Arango

dateFormat.php

Table of Contents

Functions

dateFormat()  : string
Format a date according to a specified format string.

Functions

dateFormat()

Format a date according to a specified format string.

dateFormat([null|string|int $date = null ][, string $format = DateFormat::ISO8601 ][, bool $useQuotes = true ]) : string

Constructs an AQL expression in the format:

DATE_FORMAT(date, format)

The format string supports the following placeholders (case-insensitive):

  • %t – timestamp in milliseconds since 1970-01-01T00:00:00Z
  • %z – ISO date (0000-00-00T00:00:00.000Z)
  • %w – day of week (0..6)
  • %y – year (0..9999)
  • %yy – last two digits of year
  • %yyyy – padded year (0000..9999)
  • %yyyyyy – signed and padded year (-009999..+009999)
  • %m – month (1..12)
  • %mm – month padded to 2 digits
  • %d – day (1..31)
  • %dd – day padded to 2 digits
  • %h – hour (0..23)
  • %hh – hour padded to 2 digits
  • %i – minute (0..59)
  • %ii – minute padded to 2 digits
  • %s – second (0..59)
  • %ss – second padded to 2 digits
  • %f – millisecond (0..999)
  • %fff – millisecond padded to 3 digits
  • %x – day of year (1..366)
  • %xxx – day of year padded to 3 digits
  • %k – ISO week number (1..53)
  • %kk – ISO week number padded to 2 digits
  • %l – leap year (0 or 1)
  • %q – quarter (1..4)
  • %a – days in month (28..31)
  • %mmm – abbreviated English month name (Jan..Dec)
  • %mmmm – full English month name (January..December)
  • %www – abbreviated English weekday name (Sun..Sat)
  • %wwww – full English weekday name (Sunday..Saturday)
  • %& – special escape sequence
  • %% – literal %
  • % – ignored
Parameters
$date : null|string|int = null

A numeric timestamp or ISO 8601 date string. Defaults to DATE_NOW() if null.

$format : string = DateFormat::ISO8601

Format string using placeholders (default: DateFormat::ISO8601).

$useQuotes : bool = true

Whether to wrap the expression (default: true).

Tags
example
dateFormat(dateNow(), "%q/%yyyy"); // "3/2015" (quarter/year)
dateFormat(dateNow(), "%dd.%mm.%yyyy %hh:%ii:%ss,%fff"); // "18.09.2015 15:30:49,374"
dateFormat("1969", "Summer of '%yy"); // "Summer of '69"
dateFormat("2016", "%%l = %l"); // "%l = 1" (leap year)
dateFormat("2016-03-01", "%xxx%"); // "063", trailing % ignored
see
DateFormat
https://docs.arangodb.com/3.11/aql/functions/date/#date_format
Return values
string

AQL expression returning the formatted date string.

On this page

Search results