Good afternoon
I am trying to figure something out, maybe somebody can help me. I looked into this tutorial https://support.wix.com/en/article/corvid-creating-a-bookings-timetable but it is not exactly what I am looking for.
Does anyone have a tip of how to do the following:
I have a button I want to link to two pages, Page A and Page B. But I want to use the button to go to Page A from 10am to 2pm and to Page B from 2pm to 8pm.
Any tips/ suggestions?
Thank you!
Hello horsmancreativestudio ,
i think all you have to do the right if-then-query.
That should already solve your problem.
By clicking on a button —> a function starts
export function myBUTTON(event) {myFunctionToStart()}
function myFunctionToStart(){
//…and here you do the “if-then-query” …
//. . . something like this . . .
//. . .if its time to activate site-B then do it, . . .
// . . .else activate site-A.
}
function myFunctionToStart(){
// Gets today's date and time
const today = new Date();
// Sets the property of the text element to be a string representing today's date in the user's local format
console.log(today)
console.log(today.toLocaleDateString())
console.log(today.toLocaleTimeString())
if () {} else {}
}
You have now all you need to construct your solution.
Now it’s your turn 
Ohhh, i forgot to mention, you have to use the console-window in the google-chrome-browser.
Press F-12 and go to CONSOLE.
Look which are the results after this code has been running.
Thank you for your message.
I am wondering if this way of coding could also work. What do you think?
$w.onReady(function () {
var date = new Date();
var day = date.getDay(); // Saturday is 6
var time = date.getHours(); // 7 pm is 19 & 9 pm is 21
console.log({day,time}); // console to check day and current hour
if(day === 6 && time >= 19 && time <= 21) {
$w(“#button”).show(); } });
I have also just made an example, but it’s just an example!
Look here…
Here is the code:
var myTimer
export function BTNgetDate_click(event) {
const today = new Date();
let currentDate = today.toLocaleDateString()
$w('#TXTwindow').text = currentDate
}
export function BTNgetTime_click(event) {
const today = new Date();
let currentTime = today.toLocaleTimeString()
$w('#TXTwindow').text = currentTime
}
export function BTNsetTimer_click(event) {
myTimer = $w('#input1').value
console.log(myTimer)
$w('#input2').value = myTimer
}
export function BTNcheckTime_click(event) {
const today = new Date();
let currentTime = today.toLocaleTimeString()
if (currentTime<=myTimer) {
console.log("NO-ALARM")
$w('#TXTwindow').text = "NO-ALARM"
} else {
console.log("ALARM")
$w('#TXTwindow').text = "ALARM"
}
}
export function BTNconsoleLog_click(event) {
const today = new Date();
console.log(today)
console.log("DATE = " + today.toLocaleDateString())
console.log(typeof today.toLocaleDateString())
console.log("TIME = " + today.toLocaleTimeString())
console.log(typeof today.toLocaleTimeString())
console.log("------------------")
}
And here you can test it by yourself…
https://russian-dima.wixsite.com/wixworld/date-time
Thank you Nayeli,
Are all 3 methods connected to the Wix database. Is there a way to avoid using the wix database? It only involves one button (with a link).
Thank you