The documentation suggests that parse-time-string can be fed ISO 8601 string, such as "1998-09-12T12:21:54-0200". However, (parse-time-string "1998-09-12T12:21:54-0200") returns (nil nil nil nil nil nil nil nil nil).

— Function: parse-time-string string

This function parses the time-string string into a list of the following form:

(sec min hour day mon year dow dst tz)

The format of this list is the same as what decode-time accepts (see Time Conversion), and is described in more detail there. Any element that cannot be determined from the input will be set to nil. The argument string should resemble an RFC 822 (or later) or ISO 8601 string, like “Fri, 25 Mar 2016 16:24:56 +0100” or “1998-09-12T12:21:54-0200”, but this function will attempt to parse less well-formed time strings as well.

Related question: Parsing formatted time string (inverse of format-time-string)


GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.8, cairo version 1.16.0) of 2020-01-13

  • 1
    That does seem like a bug! :-)
    – amitp
    Commented Aug 16, 2020 at 17:41
  • 1
    It is fixed in upstream emacs: it works fine in GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.13, cairo version 1.16.0) of 2020-04-23
    – NickD
    Commented Aug 16, 2020 at 18:58
  • 1
    @NickD: Please consider adding that to an existing answer or adding it as another answer. (Comments can be deleted at any time.)
    – Drew
    Commented Aug 16, 2020 at 19:01
  • 1
    @Drew: PTAL....
    – NickD
    Commented Aug 16, 2020 at 19:36

1 Answer 1



This bug was reported as bug 39001 and fixed in this commit in upstream emacs. The patch to apply can be found here.


The function parse-iso8601-time-string does parse ISO8601 string but eventually encode it with encode-time. The following snippet does what parse-time-string was supposed to do.

    (parse-iso8601-time-string "1998-09-12T12:21:54-0200"))


(54 21 16 12 9 1998 6 t 7200)


The value returned is partially wrong (the last three fields) because

(format-time-string "%Y" (decode-time 
    (parse-iso8601-time-string "1998-09-12T12:21:54-0200")))

is evaluated as 1970.


advice parse-time-string to check if its argument string matches parse-time-iso8601-regexp, if it does, apply the snippet above.

  • 1
    I hope you don't mind my adding the upstream emacs fix info to your answer. Let me know if you object.
    – NickD
    Commented Aug 16, 2020 at 19:42
  • It appears that (format-time-string "%Y" (decode-time (parse-iso8601-time-string "1998-09-12T12:21:54-0200"))) still evaluates to 1970. Emacs 28.1. Commented Sep 1, 2022 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.