Forum Discussion

Joe_D_Rozario_4's avatar
Joe_D_Rozario_4
Icon for Nimbostratus rankNimbostratus
Mar 27, 2008

date format conversion

I need some help with date-time conversion. Our servers are setting cookies with local time-stamp i.e., Thu, 09 Apr 2008 17:06:48 PDT (or PST). I am trying to find a way to convert this time-stamp to GMT i.e., Thu, 10 Apr 2008 00:06:48 PDT.

 

 

I have tried code like this:

 

 

set cookie_expires [HTTP::cookie "Expires"]

 

set x [clock scan $cookie_expires -format {%a, %d %b %Y %T %Z}]]

 

set y [clock format $x -format {%a, %d %b %Y %T %Z} -timezone :UTC]

 

 

The errors are:

 

[wrong args] on [clock scan]

 

[invalid switch] with [clock format]

 

 

Thank for your help.

 

2 Replies

  • Per the man page for clock (Click here), I don't think -format is a valid flag for clock scan. And -timezone doesn't seem to be valid for clock format. Can you give this a shot?

    
    when RULE_INIT {
       set ::date_str_orig {Thu, 09 Apr 2008 17:06:48 PDT}
       set x [clock scan $::date_str_orig]
       set y [clock format $::x -format {%a, %d %b %Y %T %Z} -gmt 1]
       log local0. "\$::date_str_orig: $::date_str_orig, \$::x: $::x, \$::y: $::y"
    }

    Log output:

    
    Rule : $date_str_orig: Thu, 09 Apr 2008 17:06:48 PDT, $x: 1207786008, $y: Thu, 10 Apr 2008 00:06:48 GMT

    Aaron
  • That works! Thanks Aaron.

     

     

    I looked up the documentation on clock in http://tmml.sourceforge.net/doc/tcl/clock.htmlSECTid8216120

     

    But the link for man page you provided has more accurate information.

     

     

    Thanks again for your help.