Рассчитать количество дней в PHP
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); } }