Last active
March 4, 2021 19:42
-
-
Save Gyvastis/ee0f6b7d146af86b2124997f4d899d6a to your computer and use it in GitHub Desktop.
visa 90 days in 180 days calculator
This file contains hidden or 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 | |
$visitDates = [ | |
['2020-06-16', '2020-06-30'], | |
['2020-07-23', '2020-07-28'], | |
['2020-10-09', '2020-11-04'], | |
['2020-12-15', '2021-01-16'], | |
['2021-01-30', '2021-02-26'], | |
]; | |
$visaDays = 90; | |
$visaWindowDays = 180; | |
$controlDate = (new DateTime('2021-04-06'))->modify(sprintf('-%d day', $visaWindowDays)); | |
// var_dump($controlDate); | |
foreach($visitDates as $visitDate) { | |
$leaveDate = new DateTime($visitDate[1]); | |
if($leaveDate < $controlDate) { | |
continue; | |
} | |
$enterDate = new DateTime($visitDate[0]); | |
if($enterDate < $controlDate) { | |
$enterDate = $controlDate; | |
} | |
$durationDays = $leaveDate->diff($enterDate)->days + 1; | |
// var_dump($durationDays); | |
$visaDays -= $durationDays; | |
} | |
var_dump($visaDays); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment