[R] unixtime conversion
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Jul 14 06:47:22 CEST 2007
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).
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help