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(&currentTime);

    // Convert the current time to a string representation
    char* timeString = ctime(&currentTime);

    // Print the current time
    std::cout << "Current time: " << timeString;

    return 0;
}