Convert double to time_t
问题 I have a double containing seconds. I would like to convert this into a time_t . I can't find a standard function which accomplishes this. Do I have to fill out the time_t by hand? 回答1: The type of std::time_t is unspecified. Although not defined, this is almost always an integral value holding the number of seconds (not counting leap seconds) since 00:00, Jan 1 1970 UTC, corresponding to POSIX time. So, just a safe casting between them could be fine. Also be carefull about portability