I’m working on a script that needs the time in 12 hour format. Is there a way to convert the time from 24 hour to 12 hour?
Thanks!
I’m working on a script that needs the time in 12 hour format. Is there a way to convert the time from 24 hour to 12 hour?
Thanks!
No one?
Is this possible?
When we do system clock get time it outputs something like 17:45. We want it to say 5:45 pm.
Can it be done?
What did I do? No one likes me!
Well for one you’re in the wrong section and this should probably be in Scripting
This probably isn’t the best method but maybe something like
:if (($CurrentTime - 12:00:00) > 00:00:00) do={:set $CurrentTime ($CurrentTime - 12:00:00)}
Havn’t tested that works, but theoretically if time is midday or earlier then it won’t change the variable, otherwise if its later than midday it’ll subtract 12 hours, effectively displaying in 12hr time
You could adjust that to also include AM/PM on the end as a string
Thanks. I’ll try it.
What if it’s midnight?
00:00:00?
Have you managed to figure it out? Do you still need some help?
Why do you need 12 hour. format? You then also need PM/AM to differentiate time of day. This only makes it mor complicated for use in other part since its not only number format.
I haven’t got it yet. I could use a lot of help!
I just tested the script I posted above and it works exactly as expected
:global CurrentTime [/system clock get time]
:put "Current time is $CurrentTime"
:if (($CurrentTime - 12:00:00) > 00:00:00) do={:set $CurrentTime ($CurrentTime - 12:00:00) ; :put "Time changed to $CurrentTime"}
Then alter the CurrentTime variable and re-test by pasting the last 2 commands
Alter with either of these commands for testing
:set $CurrentTime 12:00:01
:set $CurrentTime ($CurrentTime+05:00:00)
If time is exactly midday it doesn’t change the variable because its a ‘greater than’ comparison, not ‘greater than or equal to’. So midday doesn’t quality, only 1 second past which will display as 00:00:01
Thanks. I was asking about midnight, 00:00:00. Won’t that output as 00:00:00 or whatever time it is within that hour? I need it to output 12:15am, or something like that, not 00:15am.
In that case modify the script, check the first 2 digits and if they equal “00” then change to “12”