I want to calculate the days by write two the dates in html form we I did the code bellow I have this problem.
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Pos_Date::setDate(), 1 passed in C:\xampp\htdocs\dateTimeZone\index.php on line 40 and exactly 3 expected in C:\xampp\htdocs\dateTimeZone\Date.php:116 Stack trace: #0 C:\xampp\htdocs\dateTimeZone\index.php(40): Pos_Date->setDate('2011, 5, 5') #1 {main} thrown in C:\xampp\htdocs\dateTimeZone\Date.php on line 116
Note if I put for example 2019, 1 ,1 instead $date1 and 2020, 1 1 instead $date2 after in setDate, it works and echo 365 days left. in my class on line 116 I have this code public function setDate($year, $month, $day)
you can see the whole class and my code by this link. https://drive.google.com/drive/folders/1D406OsQyUEI4MKjSjs3XRWl4aiDyIBAt?usp=sharing
<form action="index.php" method="post">
<input type="text" name="date1">
<input type="text" name="date2">
<input type="submit" name="submit">
</form>
here is php code
$date1 = $_POST['date1'];
$date2 = $_POST['date2'];
if(isset($_POST['date1']) && isset($_POST['date2']) && isset($_POST['submit'])){
try {
$now = new Pos_Date();
$newYear = new Pos_Date();
$now->setDate(2019, 1, 1);
$newYear->setDate($date2);
$diff = $now->dateDiff2($newYear);
$unit = abs($diff) > 1 ? 'days' : 'day';
if ($diff > 0) {
echo "$diff $unit left";
}
} catch (Exception $e) {
echo $e;
}
}