c++ 时间戳、日期格式、字符串
2013-08-01 10:40
1881 查看
include<time.h>
time_t t;
t=time(0);//或者 time(&t);
time_t实际一般就是__int64,为时间戳
char now[64];
struct tm *ttime;
ttime = localtime(&t);
strftime(now,64,"%Y-%m-%d %H:%M:%S",ttime);
cout << "the time is " << now << endl;
转换为字符串 : the time is
2008-05-30 15:29:59
char
* ctime(const time_t *timer); //
char
*str_time = ctime(&t); // 转换成日历类型,包含星期几等信息
printf("str_time = %s\n", str_time);
更多参考:
/article/4695916.html
time_t t;
t=time(0);//或者 time(&t);
time_t实际一般就是__int64,为时间戳
char now[64];
struct tm *ttime;
ttime = localtime(&t);
strftime(now,64,"%Y-%m-%d %H:%M:%S",ttime);
cout << "the time is " << now << endl;
转换为字符串 : the time is
2008-05-30 15:29:59
char
* ctime(const time_t *timer); //
char
*str_time = ctime(&t); // 转换成日历类型,包含星期几等信息
printf("str_time = %s\n", str_time);
更多参考:
/article/4695916.html
相关文章推荐
- SQL Server日期时间格式转换字符串详解
- 【转】C#语言之“string格式的日期时间字符串转为DateTime类型”的方法
- sql server日期时间格式转换字符串简介
- SQL Server日期时间格式转换字符串详解
- SQL Server日期时间格式转换字符串详解
- Java时间戳与日期格式字符串的互转
- ios 将字符串转换为日期时间格式
- 根据时间日期格式从字符串中解析日期时间
- 时间字符串转换成日期格式字符串
- 从日期+时间的格式的字符串中取到自己想要的数值的感想
- c/c++日期时间处理与字符串string转换
- java.util.Date_与_java.sql.Date互转_及_字符串转换为日期时间格式
- Android 关于从后台获得时间的字符串转为日期格式再变成字符串
- SQL Server日期时间格式转换字符串详解
- SQL Server日期时间格式转换字符串详解
- SQL Server日期时间格式转换字符串详解
- IOS将字符串转换为日期时间格式
- java.util.Date_与_java.sql.Date互转_及_字符串转换为日期时间格式
- C#语言之“string格式的日期时间字符串转为DateTime类型”的方法
- pandas的to_datetime进行字符串格式化成为日期时间格式的方法