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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert EDT time to GMT

Status
Not open for further replies.

huskers

Programmer
Jan 29, 2002
75
US
Can anyone tell me how I can convert Eastern Daylight Savings Time to GMT. I presently do
set time [clock seconds]. Is there any way in Tcl to acheive this.

Thanks
 
You can use the -gmt option of the clock command.

From the clock page of the Tcl manual:
If the -format argument is not specified, the format string "%a %b %d %H:%M:%S %Z %Y" is used. If the -gmt argument is present the next argument must be a boolean which if true specifies that the time will be formatted as Greenwich Mean Time. If false then the local timezone will be used as defined by the operating environment.
Code:
  puts [clock format [clock seconds] -gmt 0]
->
Thu Jul 24 07:48:34 Paris, Madrid (heure d'été) 2003
  puts [clock format [clock seconds] -gmt 1]
->
Thu Jul 24 05:48:34 GMT 2003
HTH

ulis
 
Thanks for the response.....I got the GMT time using

set gmtdate [clock format [clock seconds] -gmt 1]
Thu Jul 24 13:41:56 EST 2003

but i need it in unix long time so when i use

set gmttime [clock scan $gmtdate] i get
1059072215 -- Thu Jul 24 14:41:35 2003

which is one hour ahead. Can you tell me how i can solve this.




 
I made it work in the following way:

set gmtdate [clock format [clock seconds] -format "%H:%M:%S" -gmt 1]
set gmttime [clock scan "$gmtdate"]

I send the time to another server using
puts $sock "Date: [HttpdDate [expr $gmttime + 120]]"

the other server should get time with GMT suffix for it to recognize the format but using the above steps i get it with EDT suffix...any ideas as to how i can acheive this.
 
Just one hint: Did you verified the TGZ on your first unix?

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top