如何解析毫秒? [英] How to parse milliseconds?
本文介绍了如何解析毫秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用 strptime
或任何其他函数来解析R中的毫秒级时间戳?
How do I use strptime
or any other functions to parse time stamps with milliseconds in 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"`
推荐答案
?strptime
帮助文件的礼貌(示例已更改为您的值):
Courtesy of the ?strptime
help file (with the example changed to your value):
z <- strptime("2010-01-15 13:55:23.975", "%Y-%m-%d %H:%M:%OS")
z # prints without fractional seconds
op <- options(digits.secs=3)
z
options(op) #reset options
这篇关于如何解析毫秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文