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 - <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, stored as a structure, to a character
    string. The time structure is available by calling gmtime() or
    localtime().

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

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

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

                All fields have a constant width.  The new-line character
                ('\n') and the null character ('\0') occupy the last two
                positions of the string.

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

                 'tm_sec'  :      Seconds
                 'tm_min'  :      Minutes
                 'tm_hour' :      Hours (0-24)
                 '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: gmtime() ctime() ftime() localtime() time()

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