How to convert a string that contains timezone to DateTime?

I have a huge csv file (>60 millions of lines) that contains a column with date time associated. These data are seen by Julia as string and they are formatted like that:


I have read the documentation that indicates we can make conversion by using the following logical:

format = "y-m-dTH:M:S.s" 
new_data  = Date(string,format)

The problem is the string the information about time zone
(+01:00) , so when I try to apply this function I got the error

ERROR: LoadError: ArgumentError: Unable to parse date time. Expected directive Delim(.) at char 20

I woul like to be able to convert my whole column dataframe to datetime and make operations on it. I don’t care about timezone information and I can really keep only the date time information.
Is there a way to do that ?
Thanks in advance.

1 Like

My understanding is that currently time zones are only partially implemented, so I do not think the ability to parse them currently exists.

If you don’t care about the time zone information, you could always do

DateTime(split(str, "+")[1])

on strings formatted like the one you show above.

1 Like

This package looks like what you need: TimeZones.jl.

(v1.3) pkg> add TimeZones

julia> using TimeZones

julia> ZonedDateTime("2019-01-23T04:30:00+01:00", "y-m-dTH:M:s+z")

Thanks for your tip!