convert epoch to time_t

好久不见. 提交于 2019-12-12 04:33:01

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3216139/convert-epoch-to-time-t

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!