No, no no! ![]()
When i giving you this…
test —> console.log(Date.now());
test —> console.log((new Date(‘2023-05-04T20:20:00’).getTime()![]()
…it does not mean that you implement it directly like it is into your code, like this…
$w.onReady(()=> {console.log("Page ready...");
---> console.log(Date.now());
---> console.log((new Date('2023-05-04T20:20:00').getTime()));
});
That’s a → NO-GO !!! That of course will not work, since it is not a conform JS-Syntax.
You have to implement it with the right JS-Syntax, like the following…
$w.onReady(()=> {console.log("Page ready...");
console.log(Date.now());
console.log((new Date('2023-05-04T20:20:00').getTime()));
});
And your whole code, looks like…
import wixLocation from 'wix-location';
$w.onReady(()=> {console.log("Page ready...");
//console.log(Date.now());
//console.log((new Date('2023-05-04T20:20:00').getTime()));
const redirectDate = new Date('2023-05-04T20:20:00');
console.log("Redirect-Date: ", redirectDate.getTime());
console.log(Date.now());
$w('#button15').onClick(() => {console.log("Clicked");
if (Date.now() >= redirectDate.getTime()) {console.log("GO-IF");
wixLocation.to('https://www.google.com');
} else {console.log("GO-ELSE");
wixLocation.to('/birdiesandbourbon/sorry');
}
});
});
I tested your code, changing it’s URL and it works.
Take a look onto this example and try again.
!!! Good luck and happy coding !!!
