Skip to content

Instantly share code, notes, and snippets.

@YasinPatel
Created April 17, 2022 14:47
Show Gist options
  • Save YasinPatel/1b6caf2e64d1ef954dd0474b39754ab1 to your computer and use it in GitHub Desktop.
Save YasinPatel/1b6caf2e64d1ef954dd0474b39754ab1 to your computer and use it in GitHub Desktop.
<?php
if(isset($argv[1]) && $argv[1] !=null && isset($argv[2]) && $argv[2] !=null ){
$start_arr = explode('/',$argv[1]);
$end_arr = explode('/',$argv[2]);
$start_date = $start_arr[2].'-'.$start_arr[1].'-'.$start_arr[0];
$end_date = $end_arr[2].'-'.$end_arr[1].'-'.$end_arr[0];
$start_date = strtotime($start_date);
$end_date = strtotime($end_date);
if($end_date > $start_date){
$diff = $end_date - $start_date;
}
else {
$diff = $start_date - $end_date;
}
$days = round($diff / (60 * 60 * 24));
if($days > 0){
$days = $days - 1;
}
print_r($days);
die;
}
else {
echo "Invalid input";
die;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment