![]() |
![]() |
![]() |
C++ Reference: ctime()
ctime()
Declaration
char* ctime(const time_t* kqpTime);
Description
This function converts the time_t variable that "kqpTime" points to into a null-terminated character string that describes the local time. The data type, time_t, is used to get the time from the time function, which returns the number of seconds since midnight January 1, 1970.
Example
#include <iostream>
#include <ctime>
int main() {
using namespace std;
time_t qTime;
// Get the number of seconds since midnight Jan. 1, 1970
time(&qTime);
// Convert the seconds to a string which describes the local time
char* cpLocalTime = ctime(&qTime);
cout << "The local time is " << cpLocalTime << endl;
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





