0

I created a variable to compare the course end date with current date in php but its only comparing date, not month and year... where course_end_date is fetching from Mysql and it's in varchar format that's why I create $ced and $newformat .and after the variable, the function converts the row into red color but something went wrong

Code to Get and Convert

$enddate = $get_students_row['course_end_date'];
$ced = strtotime("$enddate");
$newformat = date('d/m/Y',$ced);
$currentdate = date('d/m/Y');
$vars = array($newformat);

And Given Code change row into the red

<tr <?php if(($vars <= $currentdate)): ?> style="color:red;" <?php endif; ?>></tr>

But it's not working it still shows the row in black however if I change to $vars >= $currentdate it starts working but it does not calculate the dates properly it's only picking only current date however I am looking for is it compare date-month-year

I also Try to Create Count of $var Values so it will calculate the $var Count so that I know how many course end date is smaller than current date..its code is given below

$yes_count = 0;                                                                          
foreach($vars as $var) { if($currentdate >= $vars)
$c = $yes_count++;

Thanks in Advance

0 Answers0