Created
June 30, 2017 17:26
-
-
Save edrdesigner/6fff0726e7f4f8e2eb3b574f9d3c620f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$date_plus_60_days = new DateTime("30-06-2017"); | |
$date_plus_60_days->modify("+1 days"); | |
$date_plus_60_days->modify("+3 days"); | |
//echo $date_plus_60_days->format("D"); | |
$d_leadtime = 3; | |
$date = "30/06/2014"; | |
$pdate = str_replace('/','-',$date); | |
$date = new DateTime($pdate); | |
$date->modify("-$d_leadtime days"); | |
$ppdate = new DateTime('2014-06-25'); | |
$limit = 30; | |
do { | |
$d_weekday = strtolower($date->format("D")); | |
$i = false; | |
if ( $d_weekday == 'thu' && $d_weekday !='sun' ) { | |
$i = true; | |
do { | |
$i2 = false; | |
$limit --; | |
$d_weekday = strtolower($date->format("D")); | |
if ( $d_weekday == 'mon' && ($date > $ppdate) && $d_weekday !='sun' ) { | |
$i2 = true; | |
} else { | |
$date->modify("+1 days"); | |
} | |
if ( $limit == 0 ) { | |
break; | |
} | |
} while($i2 == false ); | |
break; | |
} else { | |
$date->modify("-1 days"); | |
} | |
} while ($i == false); | |
echo $date->format("d-m-Y").'<br />'; | |
$delivery_date = $date->modify("+$d_leadtime days"); | |
do { | |
$d_weekday = strtolower($delivery_date->format("D")); | |
$find3 = false; | |
if ( $d_weekday != 'sun' && $d_weekday == 'thu' ) { | |
$find3 = true; | |
break; | |
} else { | |
$delivery_date->modify("+1 days"); | |
} | |
} while($find3 == false); | |
echo $delivery_date->format("d-m-Y").'<br />'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment