converting datetime string to POSIXct date/time format in R

前端 未结 1 651
無奈伤痛
無奈伤痛 2020-11-30 11:24

Consider a string in the format

test <- \"YYYY-MM-DDT00:00:00.000-08:00\"

My goal is to convert those strings to POSIXct f

相关标签:
1条回答
  • 2020-11-30 11:34

    You need to specify a format for your conversion. Take a read of ?strptime to see all of the options for date formats.

    #YYYY-MM-DDT00:00:00.000-08:00
    test <- "2013-12-25T04:32:16.500-08:00"
    z <- as.POSIXct(test,format="%Y-%m-%dT%H:%M:%OS")
    op <- options(digits.secs = 3)
    z
    #[1] "2013-12-25 04:32:16.5 EST"
    
    0 讨论(0)
提交回复
热议问题