c++ 时间处理
2015-08-05 15:26
609 查看
#include <iostream> #include <time.h> void getCalendarTime() { time_t lt; lt = time(NULL); std::cout<<"The Calendar Time is "<<lt<<std::endl; //當下時間 - 1970年1月1日0時0秒 } void getProcessTime() { clock_t start, finish; double duration; start = clock(); /*do process*/ finish = clock(); duration = (double)(finish - start); std::cout<<"Process Time is "<<start<<" "<<duration<<" "<<finish<<std::endl; } void getHours() { struct tm *local; time_t t; t = time(NULL); local = localtime(&t); std::cout<<"Local hour is : "<<local->tm_hour<<std::endl; local = gmtime(&t); std::cout<<"UTC hour is : "<<local->tm_hour<<std::endl; } int main () { getCalendarTime(); getProcessTime(); getHours(); return 0; }
相关文章推荐
- C语言之static作用
- c++技术系统学习资料
- 图的拓扑排序的非递归和递归的c++实现
- VC++双缓冲保持背景不擦除之实现
- C语言-结构体内存对齐
- c++中的explicit关键字
- 用VS2008的nmake编译(libevent)C语言代码的方法
- C++中随机函数rand()和srand()的用法
- C语言-不同类型数据间的混合运算
- 统计输入字符各个字母出现频率的解题思路
- 七牛(qiniu)C/C++ SDK 实现上传
- (C/C++学习笔记)临时对象深入理解
- 深度探索C++对象模型--Function语意学
- list
- [LeetCode] Reverse Linked List II
- C++为了兼容,所以并不是纯面向对象编程语言
- stack
- C++文件操作
- set
- 设计模式之策略模式