strftime
- Updated2023-02-21
- 2 minute(s) read
strftime
size_t strftime (char timeString[], size_t maximumSize, const char formatString[], const struct tm *timeStruct);
Purpose
Takes a date and time stored in a time struct and generates a NUL-terminated ASCII string that contains the time and date information in a format specified by a format string. You can obtain the local date and time in tm by calling time or localtime.
Parameters
Input | ||||
Name | Type | Description | ||
maximumSize | size_t | Specifies the maximum number of characters to place into timeString, including the terminating ASCII NUL byte. | ||
formatString | const char [] |
Contains zero or more conversion specifiers and ordinary characters that define the desired format. The conversion specifiers are
replaced with individual members of timeStruct.
|
||
timeStruct | const struct tm * | Contains the address of tm that represents a date and time. You can obtain the local date and time in tm by calling time or localtime. | ||
Output | ||||
Name | Type | Description | ||
timeString | char [] | Contains a pointer to the string created from the date and time stored in timeStruct. If the string cannot be represented in maximumSize characters, the string's contents are indeterminate. |
Return Value
Name | Type | Description |
bytesFormatted | size_t | Contains the number of characters placed into timeString, not including the terminating ASCII NUL byte. If the total number of characters including the terminating NUL byte is more than maximumSize, the function returns zero and the contents of timeString are indeterminate. |
Additional Information
Library: ANSI C Library
Include file: ansi_c.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later
Example
Refer to userint\colview.cws for an example of using the strftime function.