This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
NewzNZ
Halfop
Posts: 68 Joined: Thu Mar 05, 2009 5:15 am
Contact:
Post
by NewzNZ » Fri Jan 12, 2018 8:24 pm
Hi all
I have a weather script that pulls data from a site to post.
It displays the time in 12 format - just wondering if there's a way to convert that to display in 24 hour format?
eg 2:35pm becomes 14:35
Thanks in advance!
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Fri Jan 12, 2018 11:58 pm
Try this maybe...
Code: Select all
set time24 [clock format [clock scan "2:35 pm" -format "%I:%M %p"] -format "%H:%M"]
NewzNZ
Halfop
Posts: 68 Joined: Thu Mar 05, 2009 5:15 am
Contact:
Post
by NewzNZ » Sat Jan 13, 2018 12:01 am
Great - thanks for the reply SpiKe^^.
Do you know if there's a way with that code to turn any 12hr time format into 24hr? Maybe with wildcards?
Cheers again.
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Jan 13, 2018 12:23 am
Lol, That time string "2:35 pm" could be the variable holding that time value you need converted:)
Code: Select all
set sometime "2:35 pm"
set time24 [clock format [clock scan $sometime -format "%I:%M %p"] -format "%H:%M"]
The exact way you might fit that into someone's script would be a little different for every script.
NewzNZ
Halfop
Posts: 68 Joined: Thu Mar 05, 2009 5:15 am
Contact:
Post
by NewzNZ » Sat Jan 13, 2018 12:42 am
Thanks! Will give that a go! =)
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Jan 13, 2018 12:48 am
Goodluck.
If ya need more help, post the weather script here.
NewzNZ
Halfop
Posts: 68 Joined: Thu Mar 05, 2009 5:15 am
Contact:
Post
by NewzNZ » Sat Jan 13, 2018 12:53 am
Will do! Thanks =)