[R-sig-Geo] Convert units hours since 1950-01-01 00:00:00 to date

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Dec 31 09:39:12 CET 2014


On Wed, Dec 31, 2014 at 6:22 AM, Eko Susilo <ekosusilo at live.com> wrote:
> as.Date(as.POSIXct(timeval, origin="1950-01-01"))


as.Date works with number of days, so try:

 > as.Date(timeval/24, origin="1950-01-01")
 [1] "2014-11-29"

as.POSIXct works with seconds, so try:

 > as.POSIXct(timeval*60*60, origin="1950-01-01")
 [1] "2014-11-29 12:00:00 GMT"

I recommend as.Date if you only want dates and not date-times and your
data is really integer days.

Barry



More information about the R-sig-Geo mailing list