public function DateRange::convertRelativeDateRange in Views Contextual Range Filter 8
Converts relative date range, "6 months ago--now", to absolute date range.
The format used for the absolute date range is the one set on this plugin, in function init().
Parameters
string $from: The start date of the range.
string $to: The end date of the range.
Return value
array Array of 2 strings.
File
- src/
Plugin/ views/ argument/ DateRange.php, line 206
Class
- DateRange
- Argument handler to accept a date range.
Namespace
Drupal\contextual_range_filter\Plugin\views\argumentCode
public function convertRelativeDateRange($from, $to) {
$format = $this->argFormat;
if (!empty($from)) {
$abs_from = strtotime($from);
$from = empty($abs_from) ? date($format) : date($format, $abs_from);
}
if (!empty($to)) {
$abs_to = strtotime($to);
$to = empty($abs_to) ? date($format) : date($format, $abs_to);
}
return [
$from,
$to,
];
}