RAD Studio |  |

strftime, wcsftime

Header File

time.h

Category

Time and Date Routines

Prototype

size_t strftime(char *s, size_t maxsize, const char *fmt, const struct tm *t);

size_t wcsftime(wchar_t *s, size_t maxsize, const wchar_t *fmt, const struct tm *t);

Description

Formats time for output.

strftime formats the time in the argument t into the array pointed to by the argument s according to the fmt specifications. All ordinary characters are copied unchanged. No more than maxsize characters are placed in s.

The time is formatted according to the current locale's LC_TIME category.

Return Value

On success, strftime returns the number of characters placed into s.

On error (if the number of characters required is greater than maxsize), strftime returns 0.

More about strftime

Example

Copy Code

    #include <stdio.h>
    #include <time.h>
    #include <dos.h>
    int main(void)
    {
       struct tm *time_now;
       time_t secs_now;
       char str[80];
       tzset();
       time(&secs_now);
       time_now = localtime(&secs_now);
       strftime(str, 80,
                "It is %M minutes after %I o'clock (%Z)  %A, %B %d 19%y",
                time_now);
       printf("%s\n",str);
       return 0;
    }

Portability

| POSIX | Win32 | ANSI C | ANSI C++
strftime | + | + | + | +
wcsftime |  | + | + | +

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!