Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clock scan

Status
Not open for further replies.

kcrist84

Programmer
Jul 14, 2008
6
0
0
US
i have been fiddling with the clock command with no luck. i am trying to format the date 201001111357 to 01/11/2010 1:57 PM. Any help would be appreciated.
Thanks
 
I think your problem is that both forms in your post are "formatted dates" so first you need to scan 201001111357 into an internal time and then format that time as 01/11/2010 1:57 PM.

First you need to make 201001111357 recognizable. That means you need to separate the time from the date and the minutes from the hours:
Code:
set t1 201001111357
set t2 [string range $t1 0 7]
set t3 [string range 8 9]
set t4 [string range 10 11]
set t [clock scan "$t2 $t3:$t4]

Now "t" is the number of seconds since Woodstock (or something like that). Now you need to format the time how you want it:
Code:
set tout [clock format $t -format "%m/%d/%Y %T %p"]


_________________
Bob Rashkin
 
Hi

Personally I would use [tt]clock[/tt] [tt]scan[/tt] with [tt]-format[/tt] :
Code:
[b]set[/b] t1 [purple]201001111357[/purple]
[b]set[/b] t [teal][[/teal][b]clock[/b] [b]scan[/b] [navy]$t1[/navy] [teal]-[/teal][b]format[/b] [green][i]"%Y%m%d%H%M"[/i][/green][teal]][/teal]
[b]set[/b] tout [teal][[/teal][b]clock[/b] [b]format[/b] [navy]$t[/navy] [teal]-[/teal][b]format[/b] [green][i]"%m/%d/%Y %T %p"[/i][/green][teal]][/teal]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top