Remove seconds from time in R

后端 未结 5 1453
灰色年华
灰色年华 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条回答
  •  旧时难觅i
    2020-12-03 23:46

    This is what you have:

    x <- structure(c(1459589625, 1459631964, 1460220433, 1460562983),
         class = c("POSIXct", "POSIXt"), tzone = "")
    

    This is what you want:

    x <- format(as.POSIXct(x), "%d-%m-%Y %H:%M")
    x
    
    [1] "02-04-2016 15:03" "03-04-2016 02:49" "09-04-2016 22:17" "13-04-2016 21:26"
    

提交回复
热议问题