i'm trying convert string representation of datetime using strftime function, results not i'm expecting.
str_dtime <- "1/2/2007 00:00:00" strftime(str_dtime, format = "%d/%m/%y %i:%m:%s") the value returned in example
"20/02/0001 12:00:00"
i'm new r , not sure wrong here. looks format settings match up, i'm not sure if there else going on?
i see 2 issues. first, strftime formats datetime object string. strptime converts string datetime object. second, "%i" format accepts values between 01-12, not include 00, in example. need use "%h" instead.
r> strptime(str_dtime, format = "%d/%m/%y %h:%m:%s") [1] "2007-02-01 cst" also note r convention not print "h:m:s" midnight.
Comments
Post a Comment