1 | initial version |
You can obtain a Unix timestamp using C++ by using the standard library function time
and then casting the result to a time_t
data type. Here's an example:
#include <iostream>
#include <ctime>
int main() {
std::time_t result = std::time(nullptr);
std::cout << "Unix timestamp: " << result << std::endl;
return 0;
}
This code will output the current Unix timestamp in seconds since the Unix epoch (January 1, 1970).