首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将数字(integer64类) UNIX时间戳转换为date time类

将数字(integer64类) UNIX时间戳转换为date time类
EN

Stack Overflow用户
提问于 2019-08-19 17:38:44
回答 1查看 221关注 0票数 1

到处都是类似的问答,但没有一个帮助我克服以下错误(我正在尝试将unix时间转换为日期时间格式):

代码语言:javascript
复制
> cur196$time
integer64
  [1] 1566204590000 1566204585000 1566204580000 1566204570000 1566204560000 1566204550000 1566204531000 1566204525000 1566204521000 1566204501000
 [11] 1566204495000 1566204491000 1566204481000 1566204464000 1566204461000 1566204451000 1566204441000 1566204434000 1566204431000 1566204420000
 [21] ...
>   cur196$time <- as.POSIXct(cur196$time, origin = "1970-01-01", tz = "GMT")
Error in as.POSIXct.default(cur196$time, origin = "1970-01-01", tz = "GMT") : 
  do not know how to convert 'cur196$time' to class “POSIXct”

编辑:

代码语言:javascript
复制
> dput(head(cur196$time))
structure(c(7.73807882277875e-312, 7.73807879807547e-312, 7.73807877337218e-312, 
7.73807872396562e-312, 7.73807867455905e-312, 7.73807862515249e-312
), class = "integer64")

编辑2:

@zx8754非常感谢您更改了标题,并指出了真正的问题- unix时间戳以毫秒为单位,因此对于转换来说太大了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-19 20:17:06

问题是您的数据具有来自bit64包的类integer64。在加载bit64包时,您需要使用as.integer()将其转换为普通整数。然后你就可以在上面使用as.POSIXct()了。

但您可能应该首先了解一下如何导入数据,以及为什么以这种方式保存数据。它需要是64位整数吗?

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57554084

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档