strftime()函数,C语言时间格式化
来源:互联网 发布:js表单提交 编辑:程序博客网 时间:2024/05/22 17:17
函数原型
#include <time.h>size_t strftime(char *str, size_t count, const char *format, const struct tm *tm);
参数说明
- str, 表示返回的时间字符串
- count, 要写入的字节的最大数量
- format, 格式字符串由零个或多个转换符和普通字符(除%)
- tm, 输入时间
返回值
- 如果包含终止的空字符在内的结果字符的总数不大于count,则函数strftime返回字符数,这些字符被放到s指向的数组中但不包含终止的空字符。否则,函数返回零,且数组的内容不确定。
格式说明
如果一个转换说明符表不是上面中的某一个,则行为未定义。
示例程序代码
#include <stdio.h>#include <time.h>int main(){ time_t time_T; time_T = time(NULL); struct tm *tmTime; // tm对象格式的时间 tmTime = localtime(&time_T); printf("Now Time is: %d:%d:%d\n", (*tmTime).tm_hour, (*tmTime).tm_min, (*tmTime).tm_sec); char* format = "%Y-%m-%d %H:%M:%S"; char strTime[100]; strftime(strTime, sizeof(strTime), format, tmTime); printf("Time is :%s\n", strTime); return 0;}// 代码结果// Now Time is: 20:46:1 // Time is :2015-10-07 20:46:01
0 0
- C语言格式化输出时间函数strftime()
- strftime()函数,C语言时间格式化
- Linux C语言 格式化输出时间函数 strftime()
- 时间格式化函数strftime
- 时间格式化函数--strftime
- C语言时间处理函数strftime
- strftime() 函数---> 时间格式化
- strftime() 函数将时间格式化
- strftime函数将时间格式化
- strftime函数将时间格式化
- strftime()函数将时间格式化
- strftime()函数将时间格式化
- strftime()函数将时间格式化
- strftime()函数将时间格式化
- strftime()函数将时间格式化
- strftime()函数将时间格式化
- strftime()函数将时间格式化
- strftime()函数将时间格式化
- NetBeans GUI编程基本步骤
- Redhat Linux下开启telnet服务
- POJ2677.Tour
- c语言中地址加法与减法
- 【妄言之言】遇见
- strftime()函数,C语言时间格式化
- Lintcode 比较字符串
- 软件生命周期之软件计划阶段
- 字符匹配 kmp算法
- 设计模式学习--策略模式
- android源码编译出错(2)
- iOS9 http不能访问网络——在Xcode中将https改成http方式
- apache2.2以后,每次升级系统,比如Yosemite 或者 EL Capitan版本 apache都要重新配置
- JSP原理,语法,内置对象