Remove seconds from time in R

后端 未结 5 1454
灰色年华
灰色年华 2020-12-03 23:00

I am trying to remove the seconds from a column of hours in POSIXct format:

#\"2016-04-02 10:33:45 COT\" \"2016-04-02 22:19:24 COT\"
#\"2016-04-09 17:47:13 C         


        
5条回答
  •  不知归路
    2020-12-03 23:32

    If you want to round date to minutes you can do this:

       x <- as.POSIXlt(c("2016-04-02 10:33:45 COT"))
       res <-as.POSIXlt(floor(as.double(x) / 60) * 60, origin = '1970-01-01')
       res
       #  "2016-04-02 10:33:00 BST"
    

提交回复
热议问题