-1

if the age of the child is 1 year old because the child birthdate is year 2020 then the child need to be vaccinated at the age of 2 years old then how can I get the date of the child vaccination that is supposed to be in year 2021?

$fname = $_POST['fname'];
$addre = $_POST['addre'];
$purok = $_POST['purok'];
$num = $_POST['num'];
$bdate = date('Y-m-d', strtotime($_POST['bdate']));
$mname = $_POST['mname'];
$ubrananay = $_POST['ubrananay'];
$tname = $_POST['tname'];
$ubratatay = $_POST['ubratatay'];
$bweight = $_POST['bweight'];
$tbirth = $_POST['tbirth'];
$pbirth = $_POST['pbirth'];
$ba = $_POST['ba'];
//$bcg = $_POST['bcg'];
$bcg = date($bdate'Y-m-d', strtotime('+1 year'));
  • 1
    Please enable error reporting `$bcg = date($bdate'Y-m-d', strtotime('+1 year'));` should throw an error for you. The `strtotime('+1 year')` is close to what you want... but use 3 and pass in the date. – user3783243 Nov 10 '21 at 16:09
  • @DripKartel Please update the code in your question on the last line `$bcg = date('Y-m-d', strtotime('+1 year', strtotime($bdate)));` to fix the error and enable error reporting as @user3783243 suggested. If there is **submit for review** option to re-opening the question please check it. – vee Nov 10 '21 at 17:55
  • About your question to get schedule date/year. I assume that `$bdate` is in format Y-m-d. Use `date('Y-m-d', strtotime('+2 year', strtotime($bdate)))` will get the actual date for vaccination in next 2 years. – vee Nov 10 '21 at 18:32

1 Answers1

0
$futureDate=date('Y-m-d', strtotime('+3 year', strtotime($_POST['bdate'])) );

have fun :)

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 10 '21 at 16:16
  • I'm sorry I got the question wrong. this is my final question if the age of the child is 1 year old because the child birthdate is year 2020 then the child need to be vaccinated at the age of 2 years old then how can i get the date of the child vaccination that is supposed to be in year 2021? – Drip Kartel Nov 10 '21 at 16:24
  • 1
    @DripKartel Please update your question on the top. – vee Nov 10 '21 at 16:28