Hi I am trying to basically, store current date, get the date of when user registered and compare to set number of days which is 7 See code below - basically, the user is allowed 7 days to complete something. What I want to do is, Set the amount of days to 7 and then this can be compared with the dates so it outputs how many days they have left..so when they first go onto the web page, itl start of with 7 and countsdown the days 6,5,4,3,2,1... each day Can someone help with the below?
<?php include ("dbConnect.php"); $UserID =$_SESSION['currentUserID']; $dbQuery=$conn->prepare("select Date from Results where UserID=$UserID"); $dbQuery->execute(); while($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)) { $StartDate=$dbRow['Date']; $CurrDate= date("Y-m-d"); $Days=7; -added function dayCount($CurrDate, $StartDate) { $first_date = strtotime($StartDate); $second_date = strtotime($CurrDate); $days_diff = $second_date - $first_date; return date('d',$days_diff); } }
$first_date = strtotime("03/04/18"); var_dump($first_date); $second_date = strtotime("03/27/18"); var_dump($second_date); $secs_diff = $second_date - $first_date; var_dump($secs_diff); $days = $secs_diff / 86400; var_dump($days);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)