Jump to content

Help needed with date. 5-7 working days in advance


jonnyw6969

Recommended Posts

Hi,

Im trying to write a script that will give me a date 5 working days from the date someone orders a product.

If it was ordered today the estimated delivery date would be the 25th. 5 working days from today.

 

Many thanks for any help

Jon

there are multiple methods, the easiest being the time(); function with an offset, an example of 5 days after the current date would be:

 

time()+432000;

 

432000 is 5 days in seconds as time() deals in seconds.

 

--edit:

you can then use the date() function to extrapolate a human readable date format

 

you would need to check if its monday, if its not then you would add 2 days (weekend), and if its sunday you would only add 1 day, eg:

 

$dtime = 432000; // 5 days

if(date("D") != "Mon" && date("D") != "Sun"){
  $deliverytime = $dtime + 172800; // add 2 days
}elseif(date("D") == "Sun"){
  $deliverytime = $dtime + 86400; // add 1 day
}

$delivery = time()+$deliverytime;

 

hope this helps,

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.