Answers for "how to check date time not in range php"

PHP
1

check if date is within range php

$start_date = '2020-10-21';
$end_date = '2020-10-15';
$date_check = '2020-08-28';

if ($this->check_in_range($start_date, $end_date, $date_from_user)) {
  echo "within range";
} else {
  echo "not within range";
}

function check_in_range($start_date, $end_date, $date_from_user) {
  // Convert to timestamp
  $start = strtotime($start_date);
  $end = strtotime($end_date);
  $check = strtotime($date_from_user);

  // Check that user date is between start & end
  return (($start <= $check ) && ($check <= $end));
}
Posted by: Guest on October-21-2020

Code answers related to "how to check date time not in range php"

Browse Popular Code Answers by Language