Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does Mathematica have a built-in function to convert ISO 8601 formatted date strings (e.g. 2012-01-04T00:00:00) to a date list?

ISO 8601 strings come in a variety of formats:

Date alone: 2012-12-03
Combined date and time: 2012-12-03T22:02
Combined date and time with time zone: 2012-12-03T22:02:47.23+01

On top of that individual components can be omitted (see the Wiki page). I am looking for a solution that covers the whole ISO 8601 standard.

share|improve this question
Unfortunately I think you need to roll your own in that case. – Szabolcs Dec 3 '12 at 21:12
Whhooaaa, I'm just realizing you are the sakra! The one who was so kind to implement a findMathematica for cmake ;-) You cannot imagine how easy life is with your tool. – halirutan Dec 4 '12 at 1:18
A July 2015 blog post says the Wolfram Language is finally getting native ISO 8601 support. – duozmo Oct 16 '15 at 21:42
up vote 6 down vote accepted

You can use JLink (as already mentioned while I read JavaDoc). Searching StackOverflow brings up this highly voted answer

Converting ISO8601-compliant String to java.util.Date

I don't know whether it covers the whole standard but this works out of the box. If this is not sufficient, you can use an equivalent piece of code written for Joda Time


ParseDateString[date_String] := JavaBlock[
   StaticsVisible -> True];

This uses the DataypeConverter class which is available without in standard Java 6. It converts it into a standard date string which can then be used with DateList.


(* {2010, 1, 1, 13, 0, 0.} *)
share|improve this answer
Does this cover the whole ISO 8601 standard? The o/p wrote: "I am looking for a solution that covers the whole ISO 8601 standard." – Andreas Lauschke Dec 3 '12 at 23:20
Probably not, but I want a working example here. To put another jar in the classpath and write your own method is easy from this point IMO. – halirutan Dec 3 '12 at 23:36

As of Mathematica 10.2, DateString and DateObject support this format directly. For example:

In[1]:= DateObject["2015-09-17T03:12:44"]
Out[1]= DateObject[{2015, 9, 17}, TimeObject[{3, 12, 44.}, TimeZone -> -4.],
         TimeZone -> -4.]
share|improve this answer

Use Joda Time with JLink. Joda is fully 8601-compliant, and with JLink the whole Java universe is immediately at your fingertips from M.

I've posted a few replies in this forum using Joda Time, for example Faster alternatives for DayOfWeek

where I've mentioned that Joda Time is fully 8601-compliant.

share|improve this answer

I want to build upon @halirutan answer.

The reason why I need to build upon the answer is DatatypeConverter`parseDateTime actually returns in the following format "Mon Mar 10 21:24:10 GMT+08:00 2014", and DateList[] can't automatically interpret the returned date

Hence, I need to provide the explicit format to DateList[] to make it work in Mathematica. The explicit format is "{"DayName"," ","MonthName"," ","Day"," ", "Hour",":","Minute",":","Second"," GMT+08:00 ", "Year"}"

Please take note of the Time Zone portion. My time zone is GMT+08:00, hence I hard coded it in the explicit format. Most likely you need to update to your own time zone for it to work successfully. For example, your time zone is GMT-08:00 if you are in USA West Coast.


ParseDateString[date_String] := JavaBlock[
   StaticsVisible -> True];
   {"DayName", " ", "MonthName", " ", "Day", " ", "Hour", ":", "Minute",":", "Second", " GMT+08:00 ", "Year"}}


And the result will be

{2014, 3, 10, 21, 24, 10.}
share|improve this answer

Looks like AbsoluteTime might get you close. My examples here don't include the final 04:00.

In[1]:= AbsoluteTime["2014-07-31T10:19:08.985"]
Out[1]= 3.615790748985000*10^9

In[2]:= ToExpression /@ 
 StringSplit["2014-07-31T10:19:08.985", ("-" | "T" | ":")]
Out[2]= {2014, 7, 31, 10, 19, 8.985}

In[3]:= AbsoluteTime@%
Out[3]= 3.615790748985000*10^9
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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