Community discussions

MikroTik App
 
Wyoming
Member Candidate
Member Candidate
Topic Author
Posts: 124
Joined: Wed Jun 09, 2004 11:43 pm
Location: Wyoming

Compare Time

Thu Oct 27, 2005 1:48 am

is there a way to compare time values in scripts.

Say is the current time greater than 17:00:00.

I tried this.

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

but is always returns false.

Thanks for any help.
 
User avatar
raivis-v
Frequent Visitor
Frequent Visitor
Posts: 55
Joined: Thu Jul 14, 2005 10:21 am
Location: Latvia, Riga

Re: Compare Time

Tue Nov 15, 2005 7:15 pm

is there a way to compare time values in scripts.

Say is the current time greater than 17:00:00.

I tried this.

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

but is always returns false.

Thanks for any help.
Try this one (routerOS v 2.9):
:set hours [:tonum [:pick[/system clock get time]0 2]]
:set min   [:tonum [:pick[/system clock get time]3 5]]
:set sec   [:tonum [:pick[/system clock get time]6 8]] 
:set a ($hours*3600 + $min*60 + $sec)
:set b 61200  
:if ($a>=$b) do={}
:if ($a<$b) do={}
where 61200 is time in seconds (17:00:00). Maybe not the shortest way but atleast works for me ;)
 
Wyoming
Member Candidate
Member Candidate
Topic Author
Posts: 124
Joined: Wed Jun 09, 2004 11:43 pm
Location: Wyoming

Tue Nov 15, 2005 8:59 pm

I really only needed to see if it was after 5 or not so I just used this line.

:if ([:pick [/system clock get time] 0 2] >= 17) do={}

Thanks for your help.

Who is online

Users browsing this forum: Amaan and 77 guests