0

I have a small elearning app and I want to check against the DB for the start and end dates (from mysql) and if they meet the criteria, good, else location.redirect to expired.php??

It doesn't redirect, any suggestions?

Here's an example below...

function Timebomb() {
 
  var StartDate = <?php echo $row_product['startdate']; ?>;
  var EndDate = <?php echo $row_product['enddate']; ?>;

  var nowDate = new Date();
  var day = nowDate.getUTCDate();
  var month = nowDate.getUTCMonth();
  var correctedMonth = month + 1; 

/* Date Checker corrector */

  if (correctedMonth < 10) {
    correctedMonth = "0" + correctedMonth;
  }
   
  if (day < 10) {
    day = "0" + day;
  }

  var year = nowDate.getYear();
  if (year < 1900) {
    year = year + 1900;
  }

  var GMTdate = year + "" + correctedMonth + "" + day;

/* End of Date Correcter */

  if ((GMTdate <= EndDate) && (GMTdate >= StartDate)) {
    document.redirect('expire.php')
  }
}

Thanks,
Ted

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by nav33n
0

I actually did it in php...

Why would I rely on javascript? because I thought I could do it easier...

Thanks.
Ted

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.