Sanitize a date or date/time string, making sure it is valid, and return it
- If no date $format is specified, date will be returned as a unix timestamp.
- If given date in invalid format and can’t be made valid, or date is empty, NULL will be returned.
- If $value is an integer or string of all numbers, it is always assumed to be a unix timestamp.
- If $format and “strict” option specified, date will also validate for format and no out-of-bounds values will be converted.
Usage
// basic usage
$string = $sanitizer->date($value);
// usage with all arguments
$string = $sanitizer->date($value, $format = null, array $options = []);
Arguments
Name | Type(s) | Description |
---|---|---|
value | string, int | Date string or unix timestamp |
format (optional) | string, null | Format of date string ($value) in any wireDate(), date() or strftime() format. |
options (optional) | array | Options to modify behavior:
|
Return value
string
int
null
$sanitizer methods and properties
API reference based on ProcessWire core version 3.0.236