当前位置:编程学习 > wap >>

unixTime如何转换为QDateTime类型

如题,最近设置了history命令使之~/.bash_history显示时间,可是设置完之后,发现文件中显示的时间是Unix时间,比如1371880815。请问怎么样才能将之转换为QDateTime类型的时间。 --------------------编程问答-------------------- 我的意思是,我使用Qt编写一个函数来分析这个文件,我讲unix时间的那一串数字存为一个QString变量,之后再一步步转换为QDateTime 类型。 --------------------编程问答-------------------- 获取的是从1970年1月1日到当前的描述,你自己换算一下 --------------------编程问答-------------------- 获取的是从1970年1月1日到当前的秒数,你自己换算一下 
--------------------编程问答-------------------- 有没有什么Qt的函数,我现在找到一个方法是使用linux命令date -d@1371880815 +%Y-%m-%d\ %H:%M:%S,直接得到结果2013-06-22 14:00:15。貌似这样比自己换算快。

--------------------编程问答-------------------- date -d '1970-01-01 UTC 1371880815 seconds' --------------------编程问答-------------------- QDateTime QDateTime::fromTime_t(uint seconds) [static]
Returns a datetime whose date and time are the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC). On systems that do not support time zones, the time will be set as if local time were Qt::UTC.
补充:移动开发 ,  Qt
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,