Answer the question
In order to leave comments, you need to log in
How to show difference between today's date and date from database?
Unable to show the difference between today's date and the date from the database, which are displayed as jobs.
/*Здесь две переменные для начальной и конечной даты*/
$starting_date = date("Y-m-d", strtotime($_POST['starting_date']));
$end_date = date("Y-m-d", strtotime($_POST['end_date']));
/*Здесь я беру значения переменных из определенного задания*/
$dateStart = new DateTime($row['starting_date']);
$dateEnd = new DateTime($row['end_date']);
/*Здесь я обозначаю сегодняшнее число*/
$currentDateTime = date('d-m-Y');
/*Здесь я считаю разницу между конечной датой и сегодняшним числом*/
$dateDifference = $dateEnd->diff($currentDateTime)->format('%a');
Answer the question
In order to leave comments, you need to log in
Replace
/*Здесь я обозначаю сегодняшнее число*/
$currentDateTime = date('d-m-Y');
/*Здесь я обозначаю сегодняшнее число*/
$currentDateTime = new DateTime();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question