Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>asctime() converts time from structure to string</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 asctime()               Converts Time from Structure to String

 #include   <time.h>

 char       *asctime(time);           Pointer to the time, as string
 struct tm  *time;                    Pointer to struct defined in <time.h>

    asctime() converts a time that has been stored as a structure into a
    character string. The time structure is available by calling gmtime()
    or localtime().

    Returns:    A pointer to the character string result; no error
                return.

                asctime() produces a string, always of 26 characters,
                which has the following form:

     Sun Dec 27 02:30:00 1984\n\0

                The width of all fields is constant; the final two string
                positions are occupied, respectively, by the new-line
                character ('\n') and the null character ('\0').

      Notes:    Both gmtime() and localtime() return a pointer to the
                'tm' structure. 'tm' is defined in <time.h> as:

                  'tm_sec'  :      Seconds (0-59)
                  'tm_min'  :      Minutes (0-59)
                  'tm_hour' :      Hours (0-23)
                  'tm_mday' :      Day of month (1-31)
                  'tm_mon'  :      Month (0-11; Jan = 0)
                  'tm_year' :      Year (current year minus 1900)
                  'tm_wday' :      Day of the week (0-6; Sun = 0)
                  'tm_yday' :      Day of the year (0-365; Jan1 = 0)
                  'tm_isdst':      Non-zero if daylight saving time, zero
                                   if standard time.


   -------------------------------- Example ---------------------------------

    The following statements get the time stored as a long integer, store
    it in a structure, convert the structure to a character string, and
    print it out.

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

           long elapsetime;
           struct tm  *greentime;

           main()
           {
               time(&elapsetime);               /* Get time in seconds  */
               greentime = gmtime(&elapsetime); /* Convert to structure */
               printf("Greenwich time is %s\n",asctime(greentime));
           }



See Also: ctime() ftime() gmtime() localtime() time()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson