PHP: Next delivery date -


php newb, excuse simplicity of question.

i attempting create little echo shows 'next delivery date' based on 2 parameters: start date , interval (in either days or weeks).

what wanting able enter, instance, today 'start date' , interval (say, '3 weeks'), , have script return "your next delivery on xxx", xxx being next upcoming 3-week interval upcoming in future , including 2 days before, when switches "tomorrow". on actual date, moves next period (the delivery cannot ordered on delivery date) infinity or realistic date in future (the next 5 years?)

is possible? i've looked through previous questions, , seems reasonably trivial add locked in date (a date + set period future) didn't come across looks @ current date , thinks next recurrence be... hence ask here.

you use dateperiod this. dateperiod take datetime object start date, first parameter, dateinterval object interval on repeat, second parameter, , datetime object or integer representing ending date or number of recurrences period.

so example, if have start date of today , 3 week interval can delivery date this...

$start    = new datetime('today'); $interval = new dateinterval('p3w'); $period   = new dateperiod($start, $interval, 1, dateperiod::exclude_start_date);  foreach($period $deliverydate) {     echo "next delivery date: " . $deliverydate->format('y-m-d'); } 

this should give like...

next delivery date: 2015-08-11 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -