strptime() with %p option in non-US locale
The option %p of the hour format for strptime() function requires that locale is set to US:
> Sys.getlocale(category = "LC_TIME")
[1] "fr_FR.UTF-8"
> strptime("2004-01-17 12:49 AM", format="%Y-%m-%d %I:%M %p")
[1] NA
> Sys.setlocale(category = "LC_TIME", locale = "en_US.UTF-8" )
[1] "en_US.UTF-8"
> strptime("2004-01-17 12:49 AM", format="%Y-%m-%d %I:%M %p")
[1] "2004-01-17 00:49:00"
If your system does not allow to use "en_US.UTF-8", just indicate "C"
If your system does not allow to use "en_US.UTF-8", just indicate "C"
Commentaires
Enregistrer un commentaire