hominid4
Member
Hi. I?m using the Date element as a date picker, and am using the "PHP Allow Dates" code at the bottom of the Date Element?s wiki to disallow queried dates. I?m also using JS to disable the weekends. The code is pasted under the date element?s Advanced tab respectively.
A test disallowed date I?m using, in the format of "Y-m-d" is: 2017-02-15
Everything seems to be working correctly, except in the date picker the day before the disallowed date(s) is disabled instead of the actual disallowed date. For example, instead of 2017-02-15 being disabled, 2017-02-14 is instead.
However, if I test it, such as picking a range between 2017-02-13 and 2017-02-17, it skips "2017-02-15" correctly, returning 4 days without the 15th:
2017-02-13,2017-02-14,2017-02-16,2017-02-17
In my Date element settings, I?ve tried different variations, but all has the same result. Currently set at Local Time and Default to current date. I?ve also tried different sites on different servers, in addition to v3.5.1 and v3.5.2 Fabrik versions. Also tried different timezones converting coding; although my server is set to my timezone.
I?ve attached screenshots of what I?m seeing. Would anyone have an idea why the day before the "disabled" date is disabled instead; or experiencing the same issue? I have a hidden URL I can PM if needed.
Thanks!
J!: v3.6.5
Fabrik: v3.5.2
Quick test code I've been using:
A test disallowed date I?m using, in the format of "Y-m-d" is: 2017-02-15
Everything seems to be working correctly, except in the date picker the day before the disallowed date(s) is disabled instead of the actual disallowed date. For example, instead of 2017-02-15 being disabled, 2017-02-14 is instead.
However, if I test it, such as picking a range between 2017-02-13 and 2017-02-17, it skips "2017-02-15" correctly, returning 4 days without the 15th:
2017-02-13,2017-02-14,2017-02-16,2017-02-17
In my Date element settings, I?ve tried different variations, but all has the same result. Currently set at Local Time and Default to current date. I?ve also tried different sites on different servers, in addition to v3.5.1 and v3.5.2 Fabrik versions. Also tried different timezones converting coding; although my server is set to my timezone.
I?ve attached screenshots of what I?m seeing. Would anyone have an idea why the day before the "disabled" date is disabled instead; or experiencing the same issue? I have a hidden URL I can PM if needed.
Thanks!
J!: v3.6.5
Fabrik: v3.5.2
Quick test code I've been using:
PHP:
$disallowedDates = array('2017-02-15');
$begin = new DateTime();
$end = new DateTime('2017-12-31');
$dateInterval = DateInterval::createFromDateString('1 day');
$datePeriod = new DatePeriod($begin, $dateInterval, $end);
$allowedDates = array();
foreach($datePeriod as $dt) {
$thisDate = $dt->format('Y-m-d');
if (!in_array($thisDate, $disallowedDates)) {
$allowedDates[] = $thisDate;
}
}
return $allowedDates;
Attachments
Last edited: