Fix bug where days with string length 1 would break mysql
This commit is contained in:
parent
d1612e2804
commit
59463ebdfb
@ -49,16 +49,19 @@ $date_part_start_time = $_POST['start_time'];
|
||||
$date_part_lasts_hours = $_POST['lasts_hours'];
|
||||
$date_part_lasts_minutes = $_POST['lasts_minutes'];
|
||||
|
||||
if (strlen($date_part_start_day) < 2) {
|
||||
$date_part_start_day = "0"
|
||||
}
|
||||
|
||||
$start = ($date_part_start_mon . "-" . $date_part_start_day . " " . $date_part_start_time);
|
||||
if (sizeof(explode(":", $date_part_start_time))==2) {
|
||||
$start .= ":00";
|
||||
}
|
||||
print($start);
|
||||
|
||||
$start_date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $start);
|
||||
$stop_date = $start_date->add(new DateInterval('PT' . $date_part_lasts_hours . 'H' . $date_part_lasts_minutes . 'M'));
|
||||
$start = $start_date->format('Y-m-d H:i:s');
|
||||
$stop = $stop_date->format('Y-m-d H:i:s');
|
||||
print($stop);
|
||||
|
||||
if ($start_date >= $stop_date) {
|
||||
echo 'Invalid dates. End date must come after the start date!';
|
||||
|
Loading…
Reference in New Issue
Block a user