Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <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() converts a time pointed to by 'time' and stored as a long
    value into a string of 26 characters in the form:

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

    Field widths are constant, and the new-line character ('\n') and the
    null character ('\0') occupy the last two positions in the string.  A
    24-hour clock is used.

    'time' can be obtained from a call to time(), which returns the
    number of seconds elapsed since 00:00:00 Greenwich mean time, January
    1, 1970.

    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.


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

   -------------------------------- 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>

           time_t 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() gmtime() localtime() time()

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