1

I make a condition like this

<?php $todays_date = date("d F Y"); ?> //echo 04 June 2017
<?php $deadline_date = date("d F Y",strtotime($tugas->deadline_tugas));?> //echo 25 May 2017
<?php if ($todays_date < $deadline_date){  <--- I confused in this condition!
 echo "<a class='btn btn-primary btn-lg btn-block' href=\"student_tugas/".$tugas->id_tgs."\">Go Activate!</a>";
 }else {
    echo "<button type='button' class='btn btn-primary btn-lg btn-block' disabled='disabled'>Oops!</button>";
} ?>

I want this code run when $deadline_date has reached $todays_date and so then the button is "Oops!" but when the $deadline_date has reached $todays_date yet then the button will be show "Go Activate!". As long as $deadline_date has not reach $todays_date and so the button "Go Activate!" will be show.

Could you help me?

LF00
  • 27,015
  • 29
  • 156
  • 295
Hikaru18
  • 77
  • 1
  • 10

1 Answers1

0

your if statement is compare 2 string come from the date() function. So it will now be correctly, for example 'June' < 'May', but actually not.

Refer to this post for compare the date and the manual of date()

LF00
  • 27,015
  • 29
  • 156
  • 295