Extracting 2 digit hour from POSIXct in R

后端 未结 1 524
长发绾君心
长发绾君心 2021-01-15 01:14

I would like to extract the hour from a POSIXct time in R, but retrieve the 2 digit answer.

For example,

test=as.POSIXct(\"2015-03-02 03         


        
相关标签:
1条回答
  • 2021-01-15 01:51

    Try to do this:

    strftime(test, format="%H")
    

    to extract hours and

    strftime(test, format="%m")
    

    for month

    0 讨论(0)
提交回复
热议问题