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>strcoll() format time value into a string</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 strcoll()               Format Time Value into a String

 #include   <time.h>

 size_t strftime(string, maxsize, format, timeptr);
 char *string;                  The Output string
 size_t maxsize;                Maximum length of string
 char *format;                  Format control string
 struct tm *timeptr;            tm time structure

    strftime() takes the information in the tm time structure pointed
    to by timeptr and holding this information:

    {
    int tm_sec;    Seconds (0,59)
    int tm_min;    Minutes (0,59)
    int tm_hour;   Hours (0,23)
    int tm_mday;   Day (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 (0,365)
    int tm_isdst;  Daylight savings time flag
    }

    strftime() converts this information into a string and stores it
    in string (which can be at most maxsize characters long).

    format is a string of one or more codes preceded with a %:

     %a         Abbreviated weekday name
     %A         Full weekday name
     %b         Abbreviated month
     %B         Full month
     %c         Date and time corresponding to the locale
     %d         Day (01-31)
     %H         Hour 24-hour style (00-23)
     %I         Hour 12-hour style (01-12)
     %j         Day of the year (001-366)
     %m         Month (01-12)
     %M         Minute (00-59)
     %p         Locale's AM/PM indicator for a 12-hour clock
     %S         Second (00-61)
     %U         Week (00-53)
     %w         Weekday (0-6; Sunday is 0)
     %W         Week of the year (00-53)
     %x         Date representation for this locale
     %X         Time representation for this locale
     %y         Year (without century) (00-99)
     %Y         Year (with century)
     %z         Time zone or abbreviation
     %%         Percent sign

    Returns:    The number of characters in the resulting string
                if successful; 0 otherwise.

 Portability:   Supported by the ANSI standard.

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

        This example shows how to use strftime():

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

        void main()
        {
            char timestring[128];
            const time_t thistime;
            struct tm *daynow;

            daynow = localtime(&thistime);

            strftime(timestring, 128, "Day %d of %B year %Y.\n", daynow);
            printf(timestring);
        }


See Also: localeconv() setlocale() strxfrm()

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