Search code examples
rdatetimedate-conversion

Convert date/time in date only in R


Tried many options, but failed. Forced to ask here. I have a date/time in 1/1/2016 0:00 format.

So, I tried

start.time <- citi.bike$starttime
head(start.time)
start.date <- strftime(as.Date(start.time), format="%m/%d/%Y")
head(start.date)

I do not know why, but my date looks like "01/20/0001" "01/20/0001" "01/20/0001" "01/20/0001" "01/20/0001" "01/20/0001".

All days became as "20".

Why?


Solution

  • Or lubridate::dmy_hm("1/1/2016 0:00")