Considering a DateObject d
and TimeObject t
:
In[1]:= t = TimeObject[{14, 1, 45.`}]
In[2]:= d = DateObject[{2012, 06, 11}]
How can I achieve this result:
In[3]:= dt = DateObject[{2012, 06, 11, 14, 1, 45.`}]
Thanks!
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityConsidering a DateObject d
and TimeObject t
:
In[1]:= t = TimeObject[{14, 1, 45.`}]
In[2]:= d = DateObject[{2012, 06, 11}]
How can I achieve this result:
In[3]:= dt = DateObject[{2012, 06, 11, 14, 1, 45.`}]
Thanks!
Another, shorter way is
Append[d, t]
From the docs,
DateObject[date,time]
represents the specified date list andTimeObject
time.
If you need the list you mention in the question, just convert the DateObject
using DateList
:
DateList@Append[d, t]
(* {2012, 6, 11, 14, 1, 45.} *)
A little late to the party here but this also works:
In[28]:= DateObject[d, t]
as Szabolcs noted, the documentation references this, but doesn't give an explicit example(which I will make sure gets added).
Strip off their heads. replace them with List
and then Flatten
them:
dt=DateObject@@(List @@@ {d, t} // Flatten)
DateObject[{2012, 6, 11, 14, 1, 45.}]
Or ....
dt=DateObject @@ Join @@ {d[[1]], t[[1]]}
Join[]
the lists instead? :)
$\endgroup$
Jun 17, 2015 at 11:21
DateObject @@ Join[d[[1]], t[[1]]]
, myself… :)
$\endgroup$
Jun 17, 2015 at 11:24