Strip the date and keep the time

前端 未结 2 471
我在风中等你
我在风中等你 2020-12-30 03:46

Lots of people ask how to strip the time and keep the date, but what about the other way around? Given:

myDateTime <- \"11/02/2014 14:22:45\"
         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-30 04:25

    If the time within a GMT day is useful for your problem, you can get this with %%, the remainder operator, taking the remainder modulo 86400 (the number of seconds in a day).

    stamps <- c("2013-04-12 19:00:00", "2010-04-01 19:00:01", "2018-06-18 19:00:02")
    as.numeric(as.POSIXct(stamps)) %% 86400
    ## [1] 0 1 2
    

提交回复
热议问题