# Convert DateObject into TimeObject

How to elegantly convert from DateObject to TimeObject?

The purpose is to extract time from the DateObject and manipulate only time components afterwards.

• It seems that for the methods below to work, DateObject must contain the time. It is possible to have DateObject without the time, in which case error will be returned. A way around this is to call DateString[dateObject, {"Hour","Minute","Second", "Millisecond"}] Aug 28 '15 at 16:41

TimeObject can take a DateObject so:

datetime = DateObject[]
time = TimeObject[datetime]


Since the FullForm of a DateObject looks like this:

DateObject[List[2015,8,27],TimeObject[List[17,58,23.456762],Rule[TimeZone,-5.]],Rule[TimeZone,-5.]]

we can use Cases:

now = DateObject[]
Cases[now, TimeObject[__]][[1]]


Or even simpler:

now[[2]]

• Not anymore: probably since v11.1, the full form is DateObject[{2019, 5, 21, 12, 55, 24.6968067}, "Instant", "Gregorian", 2.]. May 21 '19 at 10:59