# How to convert a string that contains timezone to DateTime?

**URL:** <https://discourse.julialang.org/t/how-to-convert-a-string-that-contains-timezone-to-datetime/25120>\
**Category:** General Usage\
**Tags:** dates, time\
**Created:** [June 10, 2019, 4:07pm UTC](https://discourse.julialang.org/t/how-to-convert-a-string-that-contains-timezone-to-datetime/25120 "2019-06-10T16:07:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayce\_ram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayce_ram/32/3977_2.png) [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Post date:** [June 10, 2019, 4:07pm UTC](https://discourse.julialang.org/t/how-to-convert-a-string-that-contains-timezone-to-datetime/25120/1 "2019-06-10T16:07:49Z")

</div>

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:

```julia
"2019-01-23T04:30:00+01:00"

```

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

```julia
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

```julia
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.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [June 10, 2019, 5:36pm UTC](https://discourse.julialang.org/t/how-to-convert-a-string-that-contains-timezone-to-datetime/25120/2 "2019-06-10T17:36:56Z")

</div>

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

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

```

on strings formatted like the one you show above.

---

<div class="post-metadata">

**Author:** ![tkluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkluck/32/15769_2.png) [@tkluck](https://discourse.julialang.org/u/tkluck)\
**Post date:** [June 10, 2019, 6:39pm UTC](https://discourse.julialang.org/t/how-to-convert-a-string-that-contains-timezone-to-datetime/25120/3 "2019-06-10T18:39:32Z")

</div>

This package looks like what you need: [`TimeZones.jl`](https://juliatime.github.io/TimeZones.jl/stable/types/).

```julia
(v1.3) pkg> add TimeZones
<snip>

julia> using TimeZones

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

```

---

<div class="post-metadata">

**Author:** ![jayce\_ram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayce_ram/32/3977_2.png) [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Post date:** [June 11, 2019, 4:05pm UTC](https://discourse.julialang.org/t/how-to-convert-a-string-that-contains-timezone-to-datetime/25120/4 "2019-06-11T16:05:31Z")

</div>

Thanks for your tip!
