Search code examples
rtimestampposix

R: POSIXct conversion fails although local is set


I get NA's when trying to convert english dates from strings to POSIX. I am working on a german pc but I set my locale to US.

> Sys.getlocale(category = "LC_TIME")
[1] "English_United States.1252"

as.POSIXct("23-MAI-18 03:14:00",  
format="%d-%b-%y %H:%M:%S")
[1] "2018-05-23 03:14:00 CEST"

> as.POSIXct("23-MAY-18 03:14:00",  
format="%d-%b-%y %H:%M:%S")
[1] NA

Solution

  • I do not know why but setting all locale settings with Sys.setlocale("LC_ALL", "English") solved it for me.