char *  asctime ( const struct tm * tmptr );

Convert tm structure to string.
  Converts data pointed by tmptr to a string containing time and date in readable format.
  tmptr is a pointer to a tm structure as the ones returned by gmtime and localtime.
  The returned string has the following format:

Www Mmm dd hh:mm:ss yyyy
where Www is the weekday, Mmm the month in letters, dd the day of the month, hh:mm:ss the time, and yyyy the year. The string is followed by a new-line character (\n) and a terminating null-character, conforming a total of 26 characters.


Pointer to tm structure containing time and date information to be converted.

Return Value.
  A pointer to the string containing the date and time information in readable format.
  The string pointed is statically allocated and shared by ctime and asctime functions. Each time one of these functions is called the content of the string is overwritten.

  Defined in ANSI-C.


/* asctime example */
#include <stdio.h>
#include <time.h>

main ()
  time_t rawtime;
  struct tm * timeinfo;

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
  printf ( "Current date and time are: %s", asctime (timeinfo) );
  return 0;
Current date and time are: Sat May 20 15:21:51 2000

See also.
  ctime, gmtime, localtime, time

© The C++ Resources Network, 2000