Extract time from timestamp?

前端 未结 4 579
闹比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:27

    A regular expression will probably be quite efficient for this:

    x <- '2008-08-07T17:07:36Z'
    x
    ## [1] "2008-08-07T17:07:36Z"
    sub('.*T(.*)Z', '\\1', x)
    ## [1] "17:07:36"
    

提交回复
热议问题