Share feedback, ideas and get community help

Updated last year

How can i split the bot depending the real hour time ?

At a glance

The community member is using a bot to provide support and wants to handle different scenarios based on the time of day. They ask how to achieve this using JavaScript. The comments suggest using the new Date() method to get the current time and converting it to a numerical value to easily compare it against different time ranges. While there is no explicitly marked answer, the community members provide helpful suggestions on how to approach this problem.

I use the bot to give support, and i would like to do this:

Its working hour ? > goes to Chatwoot
Its night ? > goes to create a ticket

How can i do that ? javascript maybe ?
V
a
5 comments
You can use the set variable to now, and do whatever you want with the time variable.
Attachment
image.png
But to easy manipulate just the time, I would do something like this:
Plain Text
const now = new Date();
return now.getHours() + now.getMinutes() / 60;
`
This way, time will be translated to a number:
9:30 would be 9.5
17:45 would be 17.75
It works like charm !! thanks !!!
Add a reply
Sign up and join the conversation on Discord