Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <time.h>
    size_t strftime( char *s,
                     size_t maxsize,
                     const char *format,
                     const struct tm *timeptr );

    struct  tm {
      int tm_sec;   /* seconds after the minute -- [0,61] */
      int tm_min;   /* minutes after the hour   -- [0,59] */
      int tm_hour;  /* hours after midnight     -- [0,23] */
      int tm_mday;  /* day of the month         -- [1,31] */
      int tm_mon;   /* months since January     -- [0,11] */
      int tm_year;  /* years since 1900                   */
      int tm_wday;  /* days since Sunday        -- [0,6]  */
      int tm_yday;  /* days since January 1     -- [0,365]*/
      int tm_isdst; /* Daylight Savings Time flag */
    };

Description:
    The strftime function formats the time in the argument timeptr into the
    array pointed to by the argument s according to the format argument.

    The format string consists of zero or more directives and ordinary
    characters.  A directive consists of a '%' character followed by a
    character that determines the substitution that is to take place.  All
    ordinary characters are copied unchanged into the array.  No more than
    maxsize characters are placed in the array.  The format directives %D,
    %h, %n, %r, %t, and %T are from POSIX.

    %a
        locale's abbreviated weekday name

    %A
        locale's full weekday name

    %b
        locale's abbreviated month name

    %B
        locale's full month name

    %c
        locale's appropriate date and time representation

    %d
        day of the month as a decimal number (01-31)

    %D
        date in the format mm/dd/yy (POSIX)

    %h
        locale's abbreviated month name (POSIX)

    %H
        hour (24-hour clock) as a decimal number (00-23)

    %I
        hour (12-hour clock) as a decimal number (01-12)

    %j
        day of the year as a decimal number (001-366)

    %m
        month as a decimal number (01-12)

    %M
        minute as a decimal number (00-59)

    %n
        newline character (POSIX)

    %p
        locale's equivalent of either AM or PM

    %r
        12-hour clock time (01-12) using the AM/PM notation in the format
        HH:MM:SS (AM|PM) (POSIX)

    %S
        second as a decimal number (00-59)

    %t
        tab character (POSIX)

    %T
        24-hour clock time in the format HH:MM:SS (POSIX)

    %U
        week number of the year as a decimal number (00-52) where Sunday is
        the first day of the week

    %w
        weekday as a decimal number (0-6) where 0 is Sunday

    %W
        week number of the year as a decimal number (00-52) where Monday is
        the first day of the week

    %x
        locale's appropriate date representation

    %X
        locale's appropriate time representation

    %y
        year without century as a decimal number (00-99)

    %Y
        year with century as a decimal number

    %Z
        timezone name, or by no characters if no timezone exists

    %%
        character %

    When the %Z directive is specified, the  tzset function is called.

Returns:
    If the number of characters to be placed into the array is less than
    maxsize, the strftime function returns the number of characters placed
    into the array pointed to by s not including the terminating null
    character.  Otherwise, zero is returned.  When an error has occurred,
     errno contains a value indicating the type of error that has been
    detected.

See Also:
    setlocale, asctime Functions, clock, ctime Functions, difftime, gmtime Functions, localtime Functions, mktime,
    time, tzset

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

    void main()
      {
        time_t time_of_day;
        char buffer[ 80 ];

        time_of_day = time( NULL );
        strftime( buffer, 80, "Today is %A %B %d, %Y",
                   localtime( &time_of_day ) );
        printf( "%s\n", buffer );
      }

    produces the following:

    Today is Friday December 25, 1987

Classification:
    ANSI, POSIX

Systems:
    All

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