#include#include using namespace std::chrono; int main() { auto start = high_resolution_clock::now(); // code to be timed goes here auto end = high_resolution_clock::now(); auto duration = duration_cast (end - start); std::cout << "Execution time: " << duration.count() << " microseconds" << std::endl; return 0; }
#includeThis code example uses the C standard library `time` and `strftime` functions to convert the current Unix timestamp to a human-readable string. The `time(NULL)` function returns the current timestamp, and the `localtime` function converts the timestamp to a `tm` structure representing the local time. The `strftime` function formats the `tm` structure into a string using a specified format string. This example does not use any specific C++ package or library, just the standard C library.#include using namespace std; int main() { time_t now = time(NULL); struct tm tstruct; char buf[80]; tstruct = *localtime(&now); strftime(buf, sizeof(buf), "%Y-%m-%d %X", &tstruct); std::cout << buf << std::endl; return 0; }