-2

I have a JS and I want when the JS expiration date pass, the script to be disabled.

Without the TOP 3 lines of code the script works properly. I'm not sure what's wrong with the top 3 lines. Following the entire code:

#include <date.au3>
$ExpirationDate = '9/18/2013'
If _NowDate() = $ExpirationDate Then MsgBox(64, 'Info:', "")

/* TOP 3 lines above - Javascript to stop working after a certain date */

var isloggedin = true;

function bozhoShow() {
    jQuery('&quot;div[id^=\&#39;bobito-button-wrapper\&#39;]&quot;').show();
}

function ggtimer() {
    if (isloggedin == false) {
        disableclicking();
    }
    jQuery(document).ready(function () {
        var testmode = 0;
        var dohidex = ' opacity: 0; filter: alpha(opacity = 0); ';
        if (testmode == true) {
            dohidex = '';
        }
        jQuery.get('functions.php?type=2', function (data) {
            if (data.length > 3) {
                //alert(data);
                disableclicking();
            } else {
                //alert(data);
            }
        });
putvande
  • 15,068
  • 3
  • 34
  • 50

2 Answers2

2

Use something like this:

if(new Date() > new Date('2013-09-18')){
    //expired
}else{
    //valid
}

It is probably better to manage something like this on the server side, so I would suggest using PHP instead.

Giovanni P.
  • 1,017
  • 15
  • 23
  • Well I have inserted the script as advised and change the dates to 2012-09-18. However the script is still working even the year was changed to 2012 and the validation has expired. – user2110535 Aug 22 '13 at 08:31
  • it depends on what you placed where I wrote "//expired" and "//valid". Anyway, check Denys's answer – Giovanni P. Aug 22 '13 at 08:59
1
<?php
$date = strtotime("2013-08-22 12:00");
$now = time();
if($date<= $now)
{
   ?>
   <script>
   //YOUR JS SCRIPT
   </script>
   <?php
}
else
{
   ?>
   <script>
   //YOUR OTHER JS SCRIPT
   </script>
   <?php
}

?>

Hope it helps :)

(This is the PHP method, since you tagged javascript AND php)

Denys Vitali
  • 530
  • 6
  • 19