Table of Contents

asctime

   char *asctime(const struct tm *timeptr);

Description

The function asctime() converts the time in the struct ptr to a character string of the format: Day Month Date Hour:Minute:Second Year\n\0

asctime C Sourcecode Example

/* 
 * asctime example code
 * http://code-reference.com/c/time.h/asctime 
 */
#include <stdio.h>
#include <time.h>
 
int main ( void )
{
  time_t rawtime;
  struct tm * timeinfo;
 
  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
  printf ( "Current Date is: %s", asctime (timeinfo) );
 
  return 0;
}

asctime output

  Current Date is: Sat Apr 21 13:13:46 2012

see also

localtime() gmtime() time() ctime()