strftime()函数详解
来源:互联网 发布:有益网络 编辑:程序博客网 时间:2024/05/22 17:48
size_t strftime ( char * ptr, size_t maxsize, const char * format, const struct tm * timeptr );
Format time to string
Copies into ptr the content of format, expanding its format tags into the corresponding values as specified by timeptr, with a limit of maxsize characters.Parameters
- ptr Pointer to the destination array where the resulting C string is copied.
- maxsize Maximum number of characters to be copied to ptr.
- format
- C string containing any combination of regular characters and special format specifiers. These format specifiers are replaced by the function to the corresponding values to represent the time specified in timeptr. They all begin with a percentage (%) sign, and are:
specifier Replaced by Example %aAbbreviated weekday name *Thu%AFull weekday name *Thursday%bAbbreviated month name *Aug%BFull month name *August%cDate and time representation *Thu Aug 23 14:55:02 2001%dDay of the month (01-31)23%HHour in 24h format (00-23)14%IHour in 12h format (01-12)02%jDay of the year (001-366)235%mMonth as a decimal number (01-12)08%MMinute (00-59)55%pAM or PM designationPM%SSecond (00-61)02%UWeek number with the first Sunday as the first day of week one (00-53)33%wWeekday as a decimal number with Sunday as 0 (0-6)4%WWeek number with the first Monday as the first day of week one (00-53)34%xDate representation *08/23/01%XTime representation *14:55:02%yYear, last two digits (00-99)01%YYear2001%ZTimezone name or abbreviationCDT%%A % sign%* The specifiers whose description is marked with an asterisk (*) are locale-dependent. - timeptr
- Pointer to a tm structure that contains a calendar time broken down into its components (see tm).
Return Value
If the resulting C string fits in less than maxsize characters including the terminating null-character, the total number of characters copied to ptr (not including the terminating null-character) is returned.Otherwise, zero is returned and the contents of the array are indeterminate.
Portability
This description corresponds to the C++ version of this function (which is the same as in the ISO-C Standard of 1990). C compilers may support additional specifiers and modifiers for the format parameter of this function, which are not described here.Example
/* strftime example */#include <stdio.h>#include <time.h>int main (){ time_t rawtime; struct tm * timeinfo; char buffer [80]; time ( &rawtime ); timeinfo = localtime ( &rawtime ); strftime (buffer,80,"Now it's %I:%M%p.",timeinfo); puts (buffer); return 0;}Example output:
Now it's 03:21PM.
更多参见:http://www.cplusplus.com/reference/clibrary/ctime/strftime/
- strftime()函数详解
- strftime ()函数
- strftime函数
- strftime 函数
- strftime函数
- strftime操作时间详解
- strftime函数说明
- strftime,strptime系统函数
- strftime()函数的用法
- strftime()函数用法
- strftime()函数用法
- strftime函数的用法
- Linux time(),strftime()函数
- Python中的strftime函数
- 时间格式化函数strftime
- 时间格式化函数--strftime
- PHP strftime() 函数
- strftime()函数用法
- AV-Test发布最新企业级端点安全评测:云计算安全技术架构助趋势科技OfficeScan获七连胜
- 关键字__declspec概述
- 是goal还是phase?Maven插件(plugin)goal的执行与生命周期(lifecycle)phase的关系
- 根据NSArray里边的Object的某个属性进行排序
- 用Socket读取网页,但是经常出现错误
- strftime()函数详解
- PKU 3675 Telescope
- windows进程、线程和作业的基本了解
- 调用外部DLL,如:DelphiC++Java的DLL的调用方法,给出代码片段?
- 取得屏幕的宽高的问题
- buf 经典使用
- 解决出现的警告:Warning - secret file /etc/ppp/pap-secrets has world and/or group access Warning - secret fi
- [转] 80后的80条幽默有哲理的语录
- Linux中缺少so文件的问题