I am checking to see whether current time is inside a specified range but get odd behavior.
I wonder, maybe when I do $end_date->getTimestamp() I get the timestamp for the first minute of that day?
In that case I would need to add (60*60*24)-1 to the timestamp to get 23:59:59 of that $end_date right?
private function check_date_in_range($start_date, $end_date)
{
//Get current time
$user_ts = time();
if ($start_date == null && $end_date == null) {
//if both are null...
return 1;
}
elseif ($start_date != null && $end_date != null) {
// if none is null
//Convert dates to timestamp for comparison
$start_ts = $start_date->getTimestamp();
$end_ts = $end_date->getTimestamp();
// Check that current date is between start & end otherwise return FALSE.
return (($user_ts >= $start_ts) && ($user_ts <= $end_ts));