将纪元转换为time_t [英] convert epoch to time_t
本文介绍了将纪元转换为time_t的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个双倍的纪元,需要传递给需要time_t的函数。如何将纪元转换成double到time_t?我在使用C ++代码的Linux上。谢谢。
解决方案
如果您在 double
中有一个时代,应该这项工作?
time_t t = static_cast< time_t>(epoch_time);
假设您所指的时期是
< blockquote>
自1970年1月1日协调世界时00:00:00起经过的秒数。
I have a epoch in double and need to pass in to a function that takes time_t. How do I convert the epoch in double to time_t? I am on Linux with C++ code. Thanks.
解决方案
If you have the epoch in double
, shouldn't this work?
time_t t = static_cast<time_t>(epoch_time);
Assuming you mean that the epoch is the
number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time.
这篇关于将纪元转换为time_t的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文