最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Convert times created by Javascript's getTime() method to ruby Time objects - Stack Overflow

programmeradmin4浏览0评论

Javascript's getTime() method returns the number of milliseconds since midnight of January 1, 1970.

How do I convert the output of getTime() to a Ruby Time object?

Javascript's getTime() method returns the number of milliseconds since midnight of January 1, 1970.

How do I convert the output of getTime() to a Ruby Time object?

Share Improve this question asked Sep 6, 2009 at 20:22 Tom LehmanTom Lehman 89.5k72 gold badges206 silver badges279 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

You can use the Time.at method, and divide the JavaScript timestamp value by 1000, since the at method, uses seconds instead of milliseconds, for example:

jsTime = 1252268867928
print Time.at(jsTime/1000)
# Sun Sep 06 20:27:47 +0000 2009
发布评论

评论列表(0)

  1. 暂无评论