Community discussions

MikroTik App
 
torrington
just joined
Topic Author
Posts: 19
Joined: Mon Sep 04, 2017 7:05 pm

If time between help

Thu Jun 13, 2019 6:51 am

Hi, I'm trying to make a script that runs only if the time is between for example from 18:00:00pm to 04:00:00am hs.

So far I've got this one working:

:if ([/system clock get time] > "18:00:00") do={}

This one will run if time is past 18:00:00, but what I need now is to "tell" the script to only run if time is between 18:00:00pm to 04:00:00am

Thanks everyone.
 
Reinis
MikroTik Support
MikroTik Support
Posts: 87
Joined: Wed Jan 02, 2019 12:14 pm
Location: Latvia
Contact:

Re: If time between help  [SOLVED]

Thu Jun 13, 2019 9:24 am

Hi, I'm trying to make a script that runs only if the time is between for example from 18:00:00pm to 04:00:00am hs.

So far I've got this one working:

:if ([/system clock get time] > "18:00:00") do={}

This one will run if time is past 18:00:00, but what I need now is to "tell" the script to only run if time is between 18:00:00pm to 04:00:00am

Thanks everyone.
an example would be:
:local time [/system clock get time];
:if ($time >= "18:00:00" || $time <= "04:00:00") do={ :log warning time_is_between_18_and_04 } 
 
torrington
just joined
Topic Author
Posts: 19
Joined: Mon Sep 04, 2017 7:05 pm

Re: If time between help

Thu Jun 13, 2019 4:22 pm

Hi, I'm trying to make a script that runs only if the time is between for example from 18:00:00pm to 04:00:00am hs.

So far I've got this one working:

:if ([/system clock get time] > "18:00:00") do={}

This one will run if time is past 18:00:00, but what I need now is to "tell" the script to only run if time is between 18:00:00pm to 04:00:00am

Thanks everyone.
an example would be:
:local time [/system clock get time];
:if ($time >= "18:00:00" || $time <= "04:00:00") do={ :log warning time_is_between_18_and_04 } 
Thank you very much. Work Great!!
 
vadsher
just joined
Posts: 1
Joined: Tue Feb 07, 2023 9:54 am

Re: If time between help

Tue Feb 07, 2023 10:00 am

:local time [/system clock get time];
:if ($time >= "18:00:00" || $time <= "04:00:00") do={ :log warning time_is_between_18_and_04 } 
Only registered to say thanks for the ready-made code block! In my case the code looks like this:
:local time [/system clock get time];
:if ($time >= "08:30:00" || $time <= "20:30:00") do={
#Send message to Telegram
/tool fetch url="https://api.telegram.org/bot$(token)/sendMessage\?chat_id=$(id2)&text=$(msg2)" dst-path=up.txt
}
Last edited by vadsher on Tue Feb 07, 2023 10:02 am, edited 2 times in total.

Who is online

Users browsing this forum: No registered users and 19 guests