Borland C++ reference

strftime

raw OCR

Formats time for output.

Defined in header <time.h>

Syntax

#include <time.h>
size_t strftime(char *s,size_t maxsize, const char *fmt,conststruct tm *t);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

strftime formats the time in the argument t into the array pointed to by the argument s according to the fmt specifications. The format string consists of zero or more directives and ordinary characters. Like printf, a directive consists of the % character followed by a character that determines the substitution that is to take place. All ordinary characters are copied unchanged. No more than maxsize characters are placed in s.

Return value

strftime returns the number of characters placed into s. If the number of characters required is greater than maxsize, strftime returns 0.

Format specifier Substitutes

%%Character %
%aAbbreviated weekday name
%AFull weekday name
%bAbbreviated month name
%BFull month name
%cDate and time
%dTwo-digit day of the month (01 to 31)
%HTwo-digit hour (00 to 23)
%ITwo-digit hour (01 to 12)
%jThree-digit day of the year (001 to 366)
%mTwo-digit month as a decimal number (1 - 12)
%MTwo-digit minute (00 to 59)
%pAM or PM
%STwo-digit second (00 to 59)
%uTwo-digit week number where Sunday is the first day of the week (00 to 53)
%wWeekday where 0 is Sunday (0 to 6)
%WTwo-digit week number where Monday is the first day of the week (GO to 53)
%xDate
%XTime
%yTwo-digit year without century (00 to 99)
%YYear with century
%ZTime zone name, or no characters if no time zone

See also

Example

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

return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `strftirme` read as `strftime`