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 Link to comment https://forums.phpfreaks.com/topic/91655-help-needed-with-date-5-7-working-days-in-advance/ 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 Link to comment https://forums.phpfreaks.com/topic/91655-help-needed-with-date-5-7-working-days-in-advance/#findComment-469428 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 Link to comment https://forums.phpfreaks.com/topic/91655-help-needed-with-date-5-7-working-days-in-advance/#findComment-469436 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, Link to comment https://forums.phpfreaks.com/topic/91655-help-needed-with-date-5-7-working-days-in-advance/#findComment-469451 Share on other sites More sharing options...
jonnyw6969 Posted February 18, 2008 Author Share Posted February 18, 2008 Thanks that work briliantly. Link to comment https://forums.phpfreaks.com/topic/91655-help-needed-with-date-5-7-working-days-in-advance/#findComment-469454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.