Share feedback, ideas and get community help

Updated 2 months ago

Nights and Weekends messages

Hello Folks. Is there a way to detect weekdays and business hours to send specific messagens at nigh
B
m
A
8 comments
Not an easy way to that you'd have to use set variable block
Custom code to detect if current time is weekday:

Plain Text
const currentDay = new Date().getDay();
return currentDay >= 1 && currentDay <= 5;
Custom code to detect if current time is in working hours:
Plain Text
const currentHour = new Date().getHours();
return currentHour >= 9 && currentHour < 17;
Thanks a Lot Baptiste.
This code I put it at HTTP request in Integrations? Or where?
Nevermind, I found it. Script or in Variable
I solved this way:

//Weekday long form const options = { weekday: 'long' }; return new Date().toLocaleDateString('pt-BR', options).split(',')[0];

//Hour: const options = { timeZone: 'America/Sao_Paulo' }; return new Date().toLocaleTimeString('pt-BR', options).split(':')[0];
Output:
Attachment
Screenshot_2024-10-18_at_15.31.00.png
Add a reply
Sign up and join the conversation on Discord