Opencart的交货日期

I have a site on opencart, and I have this on step 4 (delivery method);

Interlink Express 24 Courier

  • Interlink Express - Get it on: Wednesday, 13th of August

I already have a code, but it does not seem to work, on Saturdays it still seems to display Sunday as the delivery date.

<?php
// Text
$_['text_title'] = 'Interlink Express 24 Courier';

$datetime = new DateTime('tomorrow');
if ($datetime->format('l') == 'Sunday') $datetime = new DateTime('tomorrow + 1 day');


$_['text_description'] = 'Interlink Express - Get it on: ' . $datetime->format('l, jS \of F ');
$_['text_weight'] = 'Weight:';
$_['text_insurance'] = 'Insured upto:';
$_['text_time'] = 'Estimated Time: Within 24 Hours'; 
?>

Also, is it possible to make it display the next date after a certain time (5:00pm) ?

So on a Monday at 5:01 it displays Wednesday instead of Tuesday.

Change these two lines

$datetime = new DateTime('tomorrow');
if ($datetime->format('l') == 'Sunday') $datetime = new DateTime('tomorrow + 1 day');

into these:

$now = new DateTime(); // uses actual date and time
if ($now->format('l') == 'Saturday') {
    // it is Saturday, delivery will be on Tuesday
    $datetime = new DateTime('tomorrow + 2 day');
} elseif ($now->format('l') == 'Sunday' || in_array($now->format('l'), array('Monday', 'Tuesday', 'Wednesday')) && ((int) $now->format('H')) > 17) {
    // it is Sunday - delivery will be on Tuesday
    // or it is working day Mon..Wed after 5 p.m. - delivery will be on second working day
    $datetime = new DateTime('tomorrow + 1 day');
} elseif (in_array($now->format('l'), array('Thursday', 'Friday')) && ((int) $now->format('H')) > 17) {
    // it is Thursday after 5 p.m. - delivery will be on next Monday
    // or it is Friday after 5 p.m. - delivery will be on next Tuesday
    $datetime = new DateTime('tomorrow + 3 day');
} else {
    $datetime = new DateTime('tomorrow');
}

This should do the trick.