[R] Extract time only from POSIXlt object

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Sun Jan 30 11:15:12 CET 2011


tt <- as.POSIXct("2011-01-29 15:00")

Note that this result can be used to add or subtract from datetime values, but I don't know of a convenient way to represent it as HH:MM:SS format.

"Simon Goodman" <s.j.goodman at leeds.ac.uk> wrote:

>How can I extract only the time component from an POSIXlt object?
>For example if I try the following it still returns both the date and
>[1] "2010-10-18 21:46:53"
>[1] "2010-10-18 21:46:53"
>round and trunc don't help...  is there an "as.Time" equivalent to
>Thanks, Simon
>View this message in context:
>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

More information about the R-help mailing list