I have used the following function to convert to POSIXct from a numeric
without any problems:

> unix2POSIXct <- function (time)   structure(time, class = c("POSIXt",
"POSIXct"))
>
> unix2POSIXct(946764000)
[1] "2000-01-01 17:00:00 EST"
>


On Fri, Feb 19, 2010 at 4:07 PM, Tim Clark <mudiver1200@yahoo.com> wrote:

> Dear List,
>
> I am having a problem with dates and I would like to understand what is
> going on.  Below is an example.  I can produce a date/time using as.POSIXct,
> but I am trying to combine two as.POSIXct objects and keep getting strange
> results.  I thought I was using the wrong origin, but according to
> structure(0,class="Date") I am not (see below).  In my example a is a simple
> date/time object, b combines it using rbind(), c converts b to a date/time
> object again using as.POSIXct and gives the incorrect time, and d combines a
> using c() and gives the correct time.  Why doesn't c give me the correct
> answer?
>
> Thanks,
>
> Tim
>
>
> > a<-as.POSIXct("2000-01-01 12:00:00")
> > a
> [1] "2000-01-01 12:00:00 HST"
>
> > b<-rbind(a,a)
> > b
>       [,1]
> a 946764000
> a 946764000
>
> > c<-as.POSIXct(b,origin="1970-01-01")
> > c
> [1] "2000-01-01 22:00:00 HST"
> [2] "2000-01-01 22:00:00 HST"
>
> > d<-c(a,a)
> > d
> [1] "2000-01-01 12:00:00 HST"
> [2] "2000-01-01 12:00:00 HST"
>
>
> > structure(0,class="Date")
> [1] "1970-01-01"
>
>
> Tim Clark
> Department of Zoology
> University of Hawaii
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

	[[alternative HTML version deleted]]

