[R] unixtime conversion

Patrick Drechsler patrick at pdrechsler.de
Sun Jul 15 13:43:24 CEST 2007


Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:

> On Sat, 14 Jul 2007, Patrick Drechsler wrote:
>
>> is there an R function to convert unixtime to one of the R time
>> formats (using chron or POSIXct)?
>>
>> Example data:
>>
>> unixtime       year  month      day     hour
>> 1183377301     2007  7          2       13
>>
>> I would like to only use the first column.
>
> See ?as.POSIXct, especially its examples.  (Isn't that the very obvious 
> place to look?)
>
> It seems you want ISOdatetime(1970,1,1,0,0,0) + unixtime
>
> although depending on the 'unix' in 'unixtime' you might have to wrorry 
> about leap seconds (which POSIX-compliant systems ignore).

Thank you very much for your reply! Indeed, ISOdatetime was the
command I was looking for.

Regards

Patrick



More information about the R-help mailing list