Skip to content
Prev 70174 / 398506 Next

print format for difftime

On 5/21/05, BXC (Bendix Carstensen) <bxc at steno.dk> wrote:
Assuming your difftime, dd, represents time since the Epoch,
convert it to units of days, dd.day, and then use chron or times
depending on whether or not its one day or more.

library(chron)
zero <- structure(0, units = "secs", class = "difftime")
dd.day <- as.vector((dd + zero)/(24*60*60))
if (dd.day < 1) times(dd.day) else chron(dd.day)