Questions tagged «strptime»

4
如何使用strftime来计算期间(AM / PM)?
具体来说,我有简化此代码: from datetime import datetime date_string = '2009-11-29 03:17 PM' format = '%Y-%m-%d %H:%M %p' my_date = datetime.strptime(date_string, format) # This prints '2009-11-29 03:17 AM' print my_date.strftime(format) 是什么赋予了?Python解析日期时是否只是忽略句点说明符,还是我做一些愚蠢的事情?

5
R中字符串到日期的转换的“标准明确日期”格式是什么?
请考虑以下 $ R --vanilla > as.Date("01 Jan 2000") Error in charToDate(x) : character string is not in a standard unambiguous format 但该日期显然是标准的明确格式。为什么会显示错误消息? 更糟糕的是,一个模棱两可的日期显然没有任何警告或错误就被接受,然后被错误地阅读! > as.Date("01/01/2000") [1] "0001-01-20" 我搜索并在[R]标记中找到包含此错误消息的28个其他问题。所有解决方案和解决方法都涉及指定iiuc格式。这个问题的不同之处在于,我要问的是,标准明确格式在哪里定义,并且可以更改吗?每个人都收到这些消息还是仅仅是我?也许与语言环境有关? 换句话说,是否有比指定格式更好的解决方案? 包含“ [R]标准明确格式”的29个问题 > sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United Kingdom.1252 [2] LC_CTYPE=English_United Kingdom.1252 [3] LC_MONETARY=English_United Kingdom.1252 …


2
如何解析毫秒?
我如何使用Rstrptime或任何其他函数解析R中的毫秒时间戳? time[1] # [1] "2010-01-15 13:55:23.975" strptime(time[1], format="%Y-%m-%d %H:%M:%S.%f") # [1] NA strptime(time[1], format="%Y-%m-%d %H:%M:%S") # [1] "2010-01-15 13:55:23"`
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.