Skip to main content

Posts

Showing posts with the label php date add days

PHP Add days into date but ignore weekends

PHP Add days into date but ignore weekends If we want to add days into php date then we can add days by below code: Add n days to current date   <? php $date = date("Y-m-d") ; echo date ( 'Y-m-d' , strtotime ( $date . ' + 1 days' )); echo date ( 'Y-m-d' , strtotime ( $date . ' + 2 days' )); ?>   Add n days to specific date   <? php $date = "2018-07-23" ; echo date ( 'Y-m-d' , strtotime ( $date . ' + 1 days' )); echo date ( 'Y-m-d' , strtotime ( $date . ' + 2 days' )); ?>     Question : But What if we want to add days to date but ignore weekends day like Saturday and Sunday ? Answer Yes we can ignore by using Weekdays with nth days. here is the example of it :- Add n days to php date but ignore saturday and sunday <?php $date = "2018-07-23" ; echo date( 'Y-m-d', strtotime($date. ' +200 Weekdays...