AM/PM string is not properly recognized by strptime

℡╲_俬逩灬. 提交于 2019-11-28 13:30:55

This is no bug, but strptime expects the information in a standardised way. %p is:

AM/PM indicator in the locale. Used in conjunction with ‘%I’ and not with ‘%H’. An empty string in some locales.

In you locale this is defined as AM/am and PM/pm. R is a formal language, and you need to stick to the rules it imposes. If you define a factor with levels flavor, color, taste, you cannot expect to be able to use colour and flavour as ways to refer to this factor. Even though it seems obvious to you that these represent the same concept, R is a formal language without human flexibility.

David Wang
library(lubridate)
mdy_hms("01/22/2013 11:00:00 PM")

The result:

[1] "2013-01-22 11:00:00 UTC"
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!