Greetings, friends, you can change the time of the format that the routerboard brings from 24 hours, to (AM-PM), according to the following example:
08:05:00 08:05:00 AM.
15:18:00 03:18:00 PM.
Thanks for your help.
EL DONCITO.
Greetings, friends, you can change the time of the format that the routerboard brings from 24 hours, to (AM-PM), according to the following example:
08:05:00 08:05:00 AM.
15:18:00 03:18:00 PM.
Thanks for your help.
EL DONCITO.
Pseudo code:
If value(<first two digits) > 12
then
newvalue=value() - 12
print new value and all the rest
print PM
else
print value as it was
print AM
endif
Start your engines …
You, as usual, do not describe entirely the request.
Where that time must be read?
Where that time must be print?
The RouterOS can not be “nationalized”.
Dummy date format and 24h clock.
24 do not exist, everytime you have from 00 to 23
00 = 12 AM
01 = 01 AM
…
11 = 11 AM
12 = 12 PM
13 = 01 PM
14 = 02 PM
…
22 = 10 PM
23 = 11 PM
Ah yes, lookup table, that’s also an option ![]()
This is the “easy” part…
:for i from=0 to=23 step=1 do={
:local hours $i
:local mhours [:tonum $hours]
:local msymbl “AM”
:if ($mhours > 11) do={:set msymbl “PM”}
:set mhours ($mhours % 12)
:if ($mhours = 0) do={:set mhours 12}
:if ($mhours < 10) do={:set mhours “0$mhours”}
:local mtime “$mhours $msymbl”
:local test $i
:if ($test < 10) do={:set test “0$test”}
:put “$test = $mtime”
}
Just for start…
It is to register it in a script but with AM-PM time
EL DONCITO.
{
:local itime [/system clock get time]
:local hours [:pick $itime 0 2]
:local minsec [:pick $itime 2 8]
:local mhours [:tonum $hours]
:local msymbl “AM”
:if ($mhours > 11) do={:set msymbl “PM”}
:set mhours ($mhours % 12)
:if ($mhours = 0) do={:set mhours 12}
:if ($mhours < 10) do={:set mhours “0$mhours”}
:local mtime “$mhours$minsec $msymbl”
:put "$itime = $mtime"
}
22:07:27 = 10:07:27 PM
Why ? Whatever you do with it afterwards, it’s in my view mostly better to use 24h format.
Always sorts nicely.
Always can be evaluated.