Sorry to ask again, just wanted to give this a nudge, please can someone help me out here, been pulling my hair out all afternoon! :(
Dec 4, 2018
13
Level 1
Incorrect Date Value
Hi all, bit stumped on small problem, I'm trying to disable dates over the Christmas period. For some reason the last date in December is returning the incorrect month. Please see my code below:
disabledDates = [
new Date(2018,3,2),
new Date(2018,2,30),
new Date(2018,4,28),
new Date(2018,7,27),
];
@php
$arrival = strtotime('-1 day', strtotime(env('CHRISTMAS_ARRIVAL_DATE')));
$return = strtotime('+1 day', strtotime(env('CHRISTMAS_RETURN_DATE')));
@endphp
christmasDates = [
@while($arrival <= $return)
@php
$month = date('n', $arrival) == 1 ? 0 : date('n', strtotime('-1 month', $arrival));
@endphp
new Date({{ date('Y', $arrival) }},{{ $month }},{{ date('d', $arrival) }}),
@php
$arrival = strtotime('+1 day', $arrival);
@endphp
@endwhile
];
$.merge(disabledDates, christmasDates);
Output
//Dates disabled...
disabledDates = [
new Date(2018,3,2),
new Date(2018,2,30),
new Date(2018,4,28),
new Date(2018,7,27),
];
christmasDates = [
new Date(2018,11,17),
new Date(2018,11,18),
new Date(2018,11,19),
new Date(2018,11,20),
new Date(2018,11,21),
new Date(2018,11,22),
new Date(2018,11,23),
new Date(2018,11,24),
new Date(2018,11,25),
new Date(2018,11,26),
new Date(2018,11,27),
new Date(2018,11,28),
new Date(2018,11,29),
new Date(2018,11,30),
new Date(2018,12,31),
new Date(2019,0,01),
new Date(2019,0,02),
new Date(2019,0,03),
new Date(2019,0,04),
new Date(2019,0,05),
new Date(2019,0,06),
new Date(2019,0,07),
new Date(2019,0,08),
new Date(2019,0,09),
new Date(2019,0,10),
];
$.merge(disabledDates, christmasDates);
I'm sure it's a simple fix, just struggling to get my mind around it, having a bit of a brain fart! Thanks folks.
Please or to participate in this conversation.