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
Return values
string —AQL expression returning the formatted date string.