Home > Mobile >  m/d/y h:m format to y-m-d h:m:s
m/d/y h:m format to y-m-d h:m:s

Time:12-05

The values under my start_time variable are in a m/d/y h:m format.

enter image description here

I want to convert it to y-m-d h:m:s, like so:

enter image description here

I've tried variations of these codes:

> parse_date_time(df$start_time)
> 
> as_date(df$start_time, format = '%Y-%m-%d') 
> 
> as.Date(as.character(df$start_time), format = "%Y-%m-%d")
> 
> as.POSIXct(df$start_time)

But i'd either get this error message - character string is not in a standard unambiguous format - or NAs.

Help!

CodePudding user response:

as.POSIXct('7/1/2019 0:01', format = '%m/%d/%Y %H:%M', tz = 'GMT')
[1] "2019-07-01 00:01:00 GMT"
  • Related