Extracting time from POSIXct

后端 未结 6 674
梦如初夏
梦如初夏 2020-11-28 23:02

How would I extract the time from a series of POSIXct objects discarding the date part?

For instance, I have:

times <- structure(c(1331086009.5009         


        
6条回答
  •  离开以前
    2020-11-28 23:04

    The data.table package has a function 'as.ITime', which can do this efficiently use below:

    library(data.table)
    x <- "2012-03-07 03:06:49 CET"
    as.IDate(x) # Output is "2012-03-07"
    as.ITime(x) # Output is "03:06:49"
    

提交回复
热议问题