Hi there
New to PHP and am struggling with a simple program I want to write. I have an HTML page which asks for a date (i.e. what date did you attend the course), I then get that data and populate a constant with it via $_POST['date_entered'].
I now want to take that date and populate a variable with it, plus one year, and then with this new variable subtract it from todays date so I can output the number of days between now and the future date.
I hope this makes sense, I am banging my head on the keyboard now!
My code is below, but if does not give the results I want:
<?php
session_start();
$_SESSION['sab']=$_POST['sab'];
echo $_SESSION['sab'];
$days_so_far = date("d/m/Y")-$_SESSION['sab'];
$year=substr($_SESSION['sab'],6,4)+1;
$month=substr($_SESSION['sab'],3,2);
$day = substr($_SESSION['sab'],0,2);
$year_ahead= $day . "/" . $month . "/" . $year;
$weeks_so_far = round($days_so_far/7,0);
$days_to_go = $year_ahead-date("d/m/Y");
echo "So far you have been back " . $days_so_far . " days<br>";
echo "Which is " . $weeks_so_far . " weeks<br>";
echo "You have " . $days_to_go . " days to go<br>";
echo "Which is " . $weeks_to_go . " weeks to go<BR>";
New to PHP and am struggling with a simple program I want to write. I have an HTML page which asks for a date (i.e. what date did you attend the course), I then get that data and populate a constant with it via $_POST['date_entered'].
I now want to take that date and populate a variable with it, plus one year, and then with this new variable subtract it from todays date so I can output the number of days between now and the future date.
I hope this makes sense, I am banging my head on the keyboard now!
My code is below, but if does not give the results I want:
<?php
session_start();
$_SESSION['sab']=$_POST['sab'];
echo $_SESSION['sab'];
$days_so_far = date("d/m/Y")-$_SESSION['sab'];
$year=substr($_SESSION['sab'],6,4)+1;
$month=substr($_SESSION['sab'],3,2);
$day = substr($_SESSION['sab'],0,2);
$year_ahead= $day . "/" . $month . "/" . $year;
$weeks_so_far = round($days_so_far/7,0);
$days_to_go = $year_ahead-date("d/m/Y");
echo "So far you have been back " . $days_so_far . " days<br>";
echo "Which is " . $weeks_so_far . " weeks<br>";
echo "You have " . $days_to_go . " days to go<br>";
echo "Which is " . $weeks_to_go . " weeks to go<BR>";