View previous topic :: View next topic |
Author |
Message |
NewzNZ Voice

Joined: 05 Mar 2009 Posts: 37
|
Posted: Fri Jan 12, 2018 8:24 pm Post subject: 12 hr > 24 hr clock |
|
|
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! |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 588 Location: Tennessee, USA
|
Posted: Fri Jan 12, 2018 11:58 pm Post subject: |
|
|
Try this maybe...
Code: | set time24 [clock format [clock scan "2:35 pm" -format "%I:%M %p"] -format "%H:%M"] |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
NewzNZ Voice

Joined: 05 Mar 2009 Posts: 37
|
Posted: Sat Jan 13, 2018 12:01 am Post subject: |
|
|
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. |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 588 Location: Tennessee, USA
|
Posted: Sat Jan 13, 2018 12:23 am Post subject: |
|
|
Lol, That time string "2:35 pm" could be the variable holding that time value you need converted:)
Code: | 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. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
NewzNZ Voice

Joined: 05 Mar 2009 Posts: 37
|
Posted: Sat Jan 13, 2018 12:42 am Post subject: |
|
|
Thanks! Will give that a go! =) |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 588 Location: Tennessee, USA
|
Posted: Sat Jan 13, 2018 12:48 am Post subject: |
|
|
Goodluck.
If ya need more help, post the weather script here. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
NewzNZ Voice

Joined: 05 Mar 2009 Posts: 37
|
Posted: Sat Jan 13, 2018 12:53 am Post subject: |
|
|
Will do! Thanks =) |
|
Back to top |
|
 |
|