How to convert to DateTime all column or array?


#1

How to convert to DateTime all column or array ?
julia> events
10×2 Array{Int64,2}:
63595231244000 63595306875000
63595195227000 63595201258000
63595205030000 63595218561000
63595182573000 63595195258000
63595234425000 63595235057000
63595234424000 63595256055000
63595162792000 63595375222000
63595214798000 63595214828000
63595215154000 63595215184000
63595214698000 63595214728000

julia> convert(DateTime, events[1,2])
2016-04-02T19:01:15

julia> convert(DateTime, events[:,2])
ERROR: MethodError: Cannot convert an object of type Array{Int64,1} to an object of type DateTime
This may have arisen from a call to the constructor DateTime(…),
since type constructors fall back to convert methods.

julia> convert.(DateTime, events[:,2])
ERROR: MethodError: no method matching size(::Type{DateTime})
Closest candidates are:
size{N}(::Any, ::Integer, ::Integer, ::Integer…) at abstractarray.jl:48
size(::BitArray{1}) at bitarray.jl:39
size(::BitArray{1}, ::Any) at bitarray.jl:43

in broadcast_shape(::Type{T}, ::Array{Int64,1}) at .\broadcast.jl:31
in broadcast_t(::Function, ::Type{Any}, ::Type{T}, ::Vararg{Any,N}) at .\broadcast.jl:213
in broadcast(::Function, ::Type{T}, ::Array{Int64,1}) at .\broadcast.jl:230
Paul


#2

I think convert. should work in Julia 0.6 but if you want something that’ll work in Julia 0.5 then this will work:

map((x) -> convert(DateTime,x),events[:,2])


How to convert period in milisecond to minutes / seconds , hour etc
#3

Thx, very nice!


#4

or

convert(Array{DateTime},events)