jonnyw6969 Posted February 18, 2008 Share Posted February 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
jonnyw6969 Posted February 18, 2008 Author Share Posted February 18, 2008 Hi, Ok, yes that sort of works but i dont want it to be on a Sat or Sun. Anyway round that? Regards Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 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, Quote Link to comment Share on other sites More sharing options...
jonnyw6969 Posted February 18, 2008 Author Share Posted February 18, 2008 Thanks that work briliantly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.