Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个脚本,并对数据库进行查询以获取表中最后输入的时间戳。所以我得到的结果是这样的:
#<UtilityReading timestamp: "2013-02-18 23:30:00">
我只是想知道如何从结果中访问日期?
例如,如果您的 UtilityReading 在名为 的变量@utility中,那么您只需调用@utility.timestamp.to_date.
@utility
@utility.timestamp.to_date
你可以试试