Бортовой журнал Ктулху

Created PHP processor for JQuery DateRangePicker

I've got a string with dates from date picker and diveded it on two parts: `from` and `to`.

Both parts has been converted into time.

This code returns two variables called $from and $to which can be used in the code.

 

/**
 * How to use
 * list('from' => $from, 'to' => $to) = Date::getRangeDatePicker($string);
 * We've got 2 variables: $from && $to
 */
 public static function getRangeDatePicker( ?string $dateRange) :array
 {
 $range = explode('-', $dateRange ?? '');
$from = !empty($range[0]) ? date('Ymd', strtotime($range[0])) : date('Ymd', strtotime('-1 month'));
 $to = !empty($range[1]) ? date('Ymd H:i:s', strtotime($range[1] . ' 23:59:59')) : date('Ymd', strtotime('+1 day'));
return compact('from', 'to');
 }