Convert 12hour time to 24Hour time

后端 未结 2 403
抹茶落季
抹茶落季 2020-12-06 18:42

I have hourly weather data. I\'ve seen the function examples from here: http://casoilresource.lawr.ucdavis.edu/drupal/node/991

I\'m altering the code to account for

相关标签:
2条回答
  • 2020-12-06 19:26

    Would strptime work?

    df2= structure(c("10:43 AM", "10:54 AM", "11:54 AM", "12:07 PM", "12:15 PM", 
                "12:54 PM", "1:54 PM", "2:54 PM"), .Dim = c(8L, 1L))
    
    
    
     strptime(df2, "%I:%M %p" )
    

    Or in case you don't want the date, something like: Although it depends what kind of class would you want for the object.

    substr(strptime(df2, "%I:%M %p" ),11,19)
    
    0 讨论(0)
  • 2020-12-06 19:33

    take a look at ?strptime.

    as.POSIXct(data$TimeEST, format='%I:%M %p')
    
    0 讨论(0)
提交回复
热议问题