运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,明暗
转到 Spaces
#include <iostream> #include <ctime> using namespace std; int main() { struct tm date; time_t now; time_t before; // Create a timestamp for right now time(&now); // Create a timestamp for 5 hours ago date = *localtime(&now); date.tm_hour -= 5; before = mktime(&date); // Calculate the difference between the two timestamps in seconds cout << difftime(now, before); return 0; }
18000