OCCI 获取系统时间函数 C++
2012-09-25 14:27
405 查看
OCCI
Date current_date = Date::getSystemDate(environment_);
C++
需要包含
#include<ctime>
time_t t = time(NULL);
tm* pt = localtime(&t);
Date current_date (environment_,(1900+pt->tm_year),pt->tm_mon,pt->tm_mday,pt->tm_hour,pt->tm_min,pt->tm_sec);
例子:
// TestTime.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
using namespace std;
void showtime(tm* pt)
{
cout<<setfill('0')<<1900 + pt->tm_year<<'-';
cout<<setw(2)<<pt->tm_mon + 1<<'-';
cout<<setw(2)<<pt->tm_mday<<' ';
cout<<setw(2)<<pt->tm_hour<<':';
cout<<setw(2)<<pt->tm_min<<':';
cout<<setw(2)<<pt->tm_sec<<'\n';
}
int _tmain(int argc, _TCHAR* argv[])
{
time_t t = time(NULL);
tm* pt = localtime(&t);
int sec = pt->tm_sec;
showtime(pt);
while(1)
{
t = time(NULL);
pt = localtime(&t);
if(sec != pt->tm_sec)
{
sec = pt->tm_sec;
system("cls");
showtime(pt);
}
}
return 0;
}
Date current_date = Date::getSystemDate(environment_);
C++
需要包含
#include<ctime>
time_t t = time(NULL);
tm* pt = localtime(&t);
Date current_date (environment_,(1900+pt->tm_year),pt->tm_mon,pt->tm_mday,pt->tm_hour,pt->tm_min,pt->tm_sec);
例子:
// TestTime.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
using namespace std;
void showtime(tm* pt)
{
cout<<setfill('0')<<1900 + pt->tm_year<<'-';
cout<<setw(2)<<pt->tm_mon + 1<<'-';
cout<<setw(2)<<pt->tm_mday<<' ';
cout<<setw(2)<<pt->tm_hour<<':';
cout<<setw(2)<<pt->tm_min<<':';
cout<<setw(2)<<pt->tm_sec<<'\n';
}
int _tmain(int argc, _TCHAR* argv[])
{
time_t t = time(NULL);
tm* pt = localtime(&t);
int sec = pt->tm_sec;
showtime(pt);
while(1)
{
t = time(NULL);
pt = localtime(&t);
if(sec != pt->tm_sec)
{
sec = pt->tm_sec;
system("cls");
showtime(pt);
}
}
return 0;
}
相关文章推荐
- C++和VC中获取系统时间函数
- C/C++获取系统时间的函数汇集
- C或C++调用Windows系统函数 实现延时 或 获取当前时间的处理
- C/C++获取系统时间的函数汇集
- C/C++下获取系统时间的函数
- c/c++获取系统时间函数
- C\C++时间处理函数[获取系统时间,求时间差,格式化输出等]
- C++获取系统时间和格林制(GMT)时间函数,并按一定格式输出
- C/C++获取系统时间的函数
- C++获取系统时间如何插入到MySQL里面的datetime型属性中
- c++ 怎样获取系统时间
- C/C++获取系统时间
- C/C++获取当前系统时间
- c++ 如何获取系统时间
- c++获取windows时间的函数(转)
- C/C++获取当前系统时间
- Linux 环境下C/C++获取系统时间 && 每隔500ms循环一次代码实现
- Windows 获取当前系统时间函数总结
- C/C++获取当前系统时间
- C/C++获取当前系统毫秒时间