ctime()

Prototype: char *ctime(const time_t *time)
Header File: time.h (C) or ctime (C++)
ANSI: C and C++
Explanation: Use ctime to convert a time_t variable into a string of 26 characters in the format Fri Jan 28 09:12:21 2000\n\0 where \n and \0 are the newline and terminating null character. The string it returns will be overwritten unless you copy the string to another variable before calling ctime again.




Example:
//Program uses ctime to convert a time_t variable into a human readable
//string in form Fri Jan 28 00:00:00 2000\n\0
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
  time_t hold_time;
  hold_time=time(NULL);
  cout<<"The date is: "<<ctime(&hold_time);
}
Other Functions