dateSubstract.php
Table of Contents
Functions
- dateSubtract() : string
- Subtract a specified amount of time units from a date and return the resulting date.
Functions
dateSubtract()
Subtract a specified amount of time units from a date and return the resulting date.
dateSubtract(int|string|null $date, int|string $amount[, string $unit = DateUnit::DAY ]) : string
Constructs an AQL expression in the format:
DATE_SUBTRACT(date, amount, unit)
datecan be a numeric timestamp or ISO 8601 string.amountis the number of units to subtract (positive value) or add (negative value, though using DATE_ADD is preferred for additions).unitspecifies the time unit.
Supported units (case-insensitive):
- y, year, years
- m, month, months
- w, week, weeks
- d, day, days
- h, hour, hours
- i, minute, minutes
- s, second, seconds
- f, millisecond, milliseconds
Parameters
- $date : int|string|null
-
Numeric timestamp or ISO 8601 date string. Defaults to
DATE_NOW()if null. - $amount : int|string
-
Number of units to subtract (positive) or add (negative).
- $unit : string = DateUnit::DAY
-
Time unit (default:
"day").
Tags
Return values
string —The AQL expression returning the calculated ISO 8601 date string.