saur12ab
(Sandu Ursu)
1
Here are 2 ways of converting UnixTime in date objects:
unixTime = Range[100000];
(1) dates = FromUnixTime /@ unixTime;
(2) dates = DateObject /@ Table[{1970, 1, 1, 2, 0, unixTime[[i]]}, {i, Length[unixTime]}];
The first method takes about 3.5 min and the second about 2 sec.
I am wondering then, what’s the point in having FromUnixTime[]?
mthiel
(Marco Thiel)
2
Hi Sandu,
I can reproduce that. Your second command should read:
dates = DateObject /@ Table[{1970, 1, 1, 1, 0, unixTime[[i]]}, {i, Length[unixTime]}];
Difficult to see why the built-in command takes about 100 times longer to evaluate.
Cheers,
Marco
saur12ab
(Sandu Ursu)
3
Hi, Marco
I used {1970, 1, 1, 2, 0, ~} to adjust for the time zone. Forgot to mention.