1

I have a timestamp string "2011-01-23T16:18:46-08:00" and I want to convert it to my local time zone.

(format-time-string  
    "%Y-%m-%dT%H:%M:%S%z" 
    (decode-time (parse-iso8601-time-string "2011-01-23T16:18:46-08:00")))

gives

"1970-02-04T13:24:34-0800"

which is off by several decades. How do I fix this?

Drew
  • 75,699
  • 9
  • 109
  • 225
Hatshepsut
  • 545
  • 3
  • 14

1 Answers1

3

parse-iso8601-time-string already returns a time value that format-time-string accepts:

(format-time-string
 "%Y-%m-%dT%H:%M:%S%z"
 (parse-iso8601-time-string "2011-01-23T16:18:46-08:00"))
     => "2011-01-24T08:18:46+0800"
xuchunyang
  • 14,302
  • 1
  • 18
  • 39