Chapter Contents

Previous

Next
asctime

asctime



Convert Time Structure to Character String

Portability: ISO/ANSI C conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <time.h>

char *asctime(const struct tm *timeinfo);


DESCRIPTION

asctime converts a broken-down time value (as stored in a tm structure) to a printable character string and returns the address of the first character of the string.

The string has the form " wkd mon dd hh:mm:ss yyyy\n ", for example " Thu Oct 10 16:49:07 1985\n ". The length of the string is always 25. The day of the month is padded with blanks on the left to two characters, if necessary (for example, Oct 09). The hours, minutes, and seconds are padded with 0s.


RETURN VALUE

asctime returns a pointer to the formatted date and time.


CAUTION

The pointer returned by asctime may reference static storage, which may be overwritten by the next call to asctime or ctime .


EXAMPLE

#include <stdio.h>
#include <time.h>

main ()
{
   time_t timeval;
   struct tm *now;

   time(&timeval);
   now = gmtime(&timeval);   /* Get current GMT time */
   printf("The current GMT time and date are: %s",
          asctime(now));
}


RELATED FUNCTIONS

ctime , strftime


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.