c++之获取当前时间
来源:互联网 发布:java 64位win7 编辑:程序博客网 时间:2024/06/05 05:29
我以为有一个Date的类,不像Java,C++没有这个类,可以使用C库time.h的函数来获取当前时间,或者调用DOS的date
方法一:
#include <iostream>#include <ctime>#include<string>using namespace std;int main (){ time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); cout<<"Current local time and date:"<< asctime (timeinfo)<<endl; system("pause"); return 0;}
方法二:
#include<iostream>#include<ctime>#include<string>using namespace std;int main(){time_t lltime;time(lltime);cout<<"the time is "<<ctime(lltime)<<endl;system("pause");return 0;}
方法三:
include <ctime>#include<string>using namespace std;#define CCT (+8)int main (){ time_t rawtime; struct tm * ptm; time ( &rawtime ); ptm = gmtime ( &rawtime ); cout<<"Beijing (China):"<<(ptm->tm_hour+CCT)%24<<":"<<ptm->tm_min<<endl; system("pause"); return 0;}
方法四:
#include<iostream>#include<string>#include<vector>using namespace std;int main(){system("time");system("pause");return 0;}
- c获取当前时间
- objective-c 获取当前时间
- objective-c 获取当前时间
- Objective-c 获取当前时间
- c语言获取当前时间
- objective-c 获取当前时间
- Objective C获取当前时间
- C/C++获取当前时间
- C中获取当前时间
- C语言获取当前时间
- c++之获取当前时间
- C++/C 获取当前系统时间
- c语言获取系统当前时间
- C/C++获取当前系统时间
- 获取当前时间---使用标准C
- C/C++获取当前系统时间
- C/C++获取当前系统时间
- C/C++获取当前系统时间
- Struts2的Ajax的学习
- openOffice+pdf2swf+flexpaper(类百度文库) :office转pdf(Linux,window)
- win32,win64编程永恒;语言编程需要注意的64位和32机器的区别
- 回调函数定义和使用
- HDU1237
- c++之获取当前时间
- linux指令大全(完整篇)
- An overview of the ARM architecture
- There is no Action mapped for namespace [/] and action name [login] associate解决办法
- 管与android软键盘隐藏总结
- java > Eclipse,svn】解决Eclipse中SVN图标不显示的问题
- tomcat日志设置
- gethostbyname() -- 用域名或主机名获取IP地
- 【集合】TreeSet类