Jump to content


New Members
  • Posts

  • Joined

  • Last visited

Everything posted by WFP

  1. seems to be working thanks!
  2. hi there - after a few hours of trying tonight I am struggling to integrate the code for my final result of outputting the code as Add to Basket now for FREE Delivery to you (est.) : Fri 03rd Sep So i assume I dont need the 'test dates' var and I can instead use the $dates but I'm missing something to link them together as below it outputs Add to Basket now for FREE Delivery to you (est.) : (<-nothing returned) $hols = bankHols(date('Y')); foreach ($dates as $d) { $ordered = new dateTime($d); $del = deliveryDate($ordered, $hols); } function deliveryDate($ordered, $hols) { $delivery = clone $ordered; if ($delivery->format('H:i') > '14:00') { // if it's after 2pm. treat is as the next day $delivery->modify('+1 day'); } if (in_array($delivery->format('w'), [0,6])) { // if it's Sat or Sun, treat it as Monday $delivery->modify('next monday'); } do { // add a day for delivery until the date isn't a holiday. $delivery->modify('+1 day'); } while (in_array($delivery->format('Y-m-d'), $hols)); return $delivery; } function bankHols($yr) { // CALC PUBLIC HOLS FOR $yr $dates = array(); $newyr = "$yr-01-01"; switch (date('w', strtotime($newyr))) { case 6: $newyr = "{$yr}-01-03"; break; case 0: $newyr = "{$yr}-01-02"; break; } $dates[] = $newyr; $easter = easter_date($yr); array_push($dates, date('Y-m-d', strtotime('-2 days', $easter)), date('Y-m-d', strtotime('+1 days', $easter))); $mayday = (new DateTime("first monday of may $yr"))->format('Y-m-d'); $dates[] = $mayday; $sbank = (new DateTime("last monday of may $yr"))->format('Y-m-d'); $dates[] = $sbank; $abank = (new DateTime("last monday of august $yr"))->format('Y-m-d'); $dates[] = $abank; $x1 = "$yr-12-25"; $x2 = "$yr-12-26"; array_push($dates, $x1, $x2); switch (date('w', strtotime($x1))) { case 5: $x2 = "$yr-12-28"; break; case 6: $x1 = "$yr-12-27"; $x2 = "$yr-12-28"; break; case 0: $x1 = "$yr-12-26"; $x2 = "$yr-12-27"; break; } array_push($dates, $x1, $x2); return $dates; } echo 'Add to Basket now for FREE Delivery to you (est.) : ' . $delivery ;
  3. thank you! very helpful indeed i would not have been able to join all the dots together like that
  4. ok great yes server was set in UTC, its on wordpress and even with settings set to london it was still returning UTC. So i added before my script the below which works fine now so 1 problem fixed date_default_timezone_set("Europe/London"); Ref the bank hols Amazing little tip there, spoon feeding abit here but im still learning at my limits - how can i integrate your function into my initial loop? p.s. I am also from cheshire UK!
  5. Hi all - I've adapted & made some basic code to forecast a delivery date for my customers but needs a little refinement - can you help? Goals & Rules > All Sat, All Sunday & Friday after 2pm = orders will arrive Tuesday (shipped Monday and Arrive Tuesday) > Monday - Friday orders before 2pm will arrive the next day (posted on 'd' arrive d+1 includes Sat). > Monday - Thursday orders after 2pm will arrive in 2 days (posted on 'd+1' and arrive d+2) Feature to be added > Bank Holidays (enter an array of all bank holiday dates upfront which will extend the delivery as per the above rules) > My current server time does not seem to recoginse changes in GMT & BST. So, when the UK is in GMT its fine (2pm = 2pm) but when we move to BST the time is 3pm but the code is reading 2pm as server looks like its still in GMT. How can this be set automatically to the correct time in the UK without editing the code for BST / GMT every time. Code so Far if(preg_match('%(Sat|Sun)%', date('D'))){ $next_working_day = date('D dS M', strtotime('next Tuesday')); } else{ if (date('H') < 14) { $next_working_day = date('D dS M', strtotime('+1 day')); } /* --for late friday orders going Mon-- */ else{ if(preg_match('%(Fri)%', date('D'))){ $next_working_day = date('D dS M', strtotime('next Tuesday')); } else {$next_working_day = date('D dS M', strtotime('+2 day'));} } } echo $next_working_day; print '</strong></p><hr>'; }
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.