时间函数---转换成指定格式的时间函数
2015-04-19 23:50
134 查看
time_t t; //秒时间
tm* local; //本地时间
tm* gmt; //格林威治时间
char buf[128]= {0};
t = time(NULL); //获取目前秒时间
local = localtime(&t); //转为本地时间
strftime(buf, 64, "%Y-%m-%d %H:%M:%S", local);
std::cout << buf << std::endl;
gmt = gmtime(&t);//转为格林威治时间
strftime(buf, 64, "%Y-%m-%d %H:%M:%S", gmt);
std::cout << buf << std::endl;
tm* local; //本地时间
tm* gmt; //格林威治时间
char buf[128]= {0};
t = time(NULL); //获取目前秒时间
local = localtime(&t); //转为本地时间
strftime(buf, 64, "%Y-%m-%d %H:%M:%S", local);
std::cout << buf << std::endl;
gmt = gmtime(&t);//转为格林威治时间
strftime(buf, 64, "%Y-%m-%d %H:%M:%S", gmt);
std::cout << buf << std::endl;
相关文章推荐
- jsp中获取系统时间,并转换成指定格式
- js 转换 Fri Sep 16 00:00:00 UTC+0800 2011 格式时间函数
- js中将时间毫秒数转换为指定的时间格式
- php UNIX时间戳转换为指定日期格式
- javascript时间戳转换成指定格式的日期
- java中日期时间格式与毫秒数的转换如何将指定时间转换为Date类型
- TimeUtils时间戳转换为指定格式的时间
- 时间格式的转换 生成指定长度的随机字符串
- js中使用eval()方法将字符串转换成日期格式、并获取指定时间的日期
- 【Python爬虫实战--2】时间戳转换为指定格式日期
- sql语句中 时间数值转换为时间格式函数
- Java将Unix时间戳转换成指定格式日期
- js 时间戳日期转换为指定格式
- 用C语言(apue)实现 把时间戳转换为国标格式的字符串(2017-07-17 22:36:12)的函数
- 将字符串转成时间指定格式的函数
- Unix时间戳转换成指定格式日期
- Java DATE类型日期转换为指定格式――取出时间与系统时间差8小时
- Java将Unix时间戳转换成指定格式日期
- 用C语言(apue)实现 把时间戳转换为国标格式的字符串(2013-09-03 15:36:12)的函数
- Java将Unix时间戳转换成指定格式日期