strftime

Navigation:  Programming language SQC > Built-in functions > Time >

strftime

Previous pageReturn to chapter overviewNext page

The contents of struct tm loctime are copied into a string of up to maxsize characters,

applying the format specifiers to create a human-readable representation of the time information saved in the

variable.

 

 

void strftime( char*buffer,int buffersize,const char* format,struct tm loctime)

 

Example:

 

struct tm 

{

   int tm_sec;      /* Seconds - [0,61] */

   int tm_min;      /* Minutes - [0,59] */

   int tm_hour;     /* Hours - [0,23] */

   int tm_mday;     /* Day of month - [1,31] */

   int tm_mon;      /* Month in year - [0,11] */

   int tm_year;     /* Year since 1900 */

   int tm_wday;     /* Day since sunday (Weekday) - [0,6] */

   int tm_yday;     /* Days since new year (1.1.) - [0,365] */

   int tm_isdst;    /* Summertime-Flag */

}ltime;

 

char buffer[180];

 

void main()

{

    int now = time();

    ltime = localtime(now);

 

    strftime(buffer,sizeof(buffer),"%d-%m-%Y %I:%M:%S",ltime);

    printf("%s",buffer);

}