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>ctime() convert time from long integer to string</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ctime()                 Convert Time from Long Integer to String

 #include   <time.h>                     Required for declarations only

 char       *ctime(time);                Pointer to character string
 const time_t *time;                     Pointer to stored time

    ctime() takes a time stored as a long value and converts it to a
    character string.  If 'time' is obtained with a call to time(),
    'time' is returned as the number of seconds elapsed since 00:00:00
    GMT, January 1, 1970.

    In MSC version 4.0, if 'time' represents a date earlier than Jan 1,
    1980, ctime() returns 00:00:00, Jan 1, 1980, the earliest date
    recognized by MS-DOS. MCS version 5.0 and later returns NULL if
    'time' represents a date earlier than January 1, 1980

    Using a 24-hour clock, ctime() produces a string of 26 characters.
    The string ends with the new-line character ('\n') and the null
    character ('\0') in the last two positions, and has the form:

                       Sun Dec 21 04:45:00 1986\n\0

    The width of each field is constant.

    Returns:    On success, a pointer to the resulting character string;
                NULL is returned if the date is before 1980.


                ctime() and asctime() use a single statically allocated
                buffer for holding the return string.  A call of either
                routine will destroy the result of any previous call.

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

    The following statements get the number of seconds elapsed since
    1/1/70, convert it to the corresponding date and time in string
    format, and print the resulting string.

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

           long elapstime;

           main()
           {
               time(&elapstime);
               printf("Number of seconds since 1-1-70: %ld \n",elapstime);
               printf("That means the current date & time is: %s \n",
                       ctime(&elapstime));
           }



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

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