gpt4 book ai didi

c++ - 将纪元转换为 time_t

转载 作者:行者123 更新时间:2023-11-28 01:11:02 25 4
gpt4 key购买 nike

我有一个 double 的纪元,需要传入一个需要 time_t 的函数。如何将 double 中的纪元转换为 time_t?我在 Linux 上使用 C++ 代码。谢谢。

最佳答案

如果你在 double 中有纪元,这不可行吗?

time_t t = static_cast<time_t>(epoch_time);

假设你的意思是纪元是

number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time.

关于c++ - 将纪元转换为 time_t,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3216139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com