Extract time from timestamp?

前端 未结 4 580
闹比i
闹比i 2020-12-11 17:28

Essentially, I want only the hour, minute, and seconds from a column of timestamps I have in R, because I want to view how often different data points occur throughout diffe

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 18:14

    I think you are expecting this...

    Sys.time()
    [1] "2016-04-19 11:09:30 IST"
    format(Sys.time(),format = '%T')
    [1] "11:09:30"
    

    if you want to give your own timestamp, then use bellow code:

    format(as.POSIXlt("2016-04-19 11:02:22 IST"),format = '%T')
    [1] "11:02:22"
    

提交回复
热议问题