Skip to content

Instantly share code, notes, and snippets.

@reindert-vetter
Last active September 21, 2018 10:44
Show Gist options
  • Save reindert-vetter/da4e646ac89fe9419da7e969363a423c to your computer and use it in GitHub Desktop.
Save reindert-vetter/da4e646ac89fe9419da7e969363a423c to your computer and use it in GitHub Desktop.
const WEEKDAY_MONDAY = 1;
/**
* Get drop off date
*
* @param int $dateTime
* @return int
*/
public function getDropOffDateTimeFromDeliveryDateTime($dateTime)
{
$weekDay = date('N', $dateTime);
if ($weekDay === self::WEEKDAY_MONDAY) {
return strtotime("-2 day", $dateTime);
}
return strtotime("-1 day", $dateTime);
}
@reindert-vetter
Copy link
Author

Make sure the day is in the future:

        if (new \DateTime() > new \DateTime($delivery_date)) {
            $datetime = new \DateTime();
            $datetime->modify('+1 day');
            $delivery_date = $datetime->format('Y\-m\-d\ h:i:s');
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment