time function c++
#include <iostream>
#include <ctime>
int main() {
// Declare a variable to store the current time
time_t currentTime;
// Get the current time and store it in the variable
time(¤tTime);
// Convert the current time to a string representation
char* timeString = ctime(¤tTime);
// Print the current time
std::cout << "Current time: " << timeString;
return 0;
}