获取系统时间
2016-01-06 15:40
471 查看
#include <time.h>
#include <sys/timeb.h>
CTime t = CTime::GetCurrentTime();
int nYear = t.GetYear() - 2000;
int nMonth = t.GetMonth();
int nDay = t.GetDay();
int nTime = t.GetHour();
int nMin = t.GetMinute();
int nSec = t.GetSecond();
CString mSecond;
struct _timeb timebuffer;
_ftime(&timebuffer);
mSecond.Format(_T("%d"), timebuffer.millitm);
int nMinSec = _ttoi(mSecond);
// srand((int)time(0));
// srand(1);
//
// int iRand = rand();
// CString sRand;
// sRand.Format(_T("%2d"), iRand);
CString str;
str.Format(_T("%2d%2d%2d%2d%2d%2d%2d"), nYear,nMonth, nDay,nTime,nMin,nSec,nMinSec);
str.Replace(_T(' '), _T('0'));
精确到毫秒
#include <sys/timeb.h>
CTime t = CTime::GetCurrentTime();
int nYear = t.GetYear() - 2000;
int nMonth = t.GetMonth();
int nDay = t.GetDay();
int nTime = t.GetHour();
int nMin = t.GetMinute();
int nSec = t.GetSecond();
CString mSecond;
struct _timeb timebuffer;
_ftime(&timebuffer);
mSecond.Format(_T("%d"), timebuffer.millitm);
int nMinSec = _ttoi(mSecond);
// srand((int)time(0));
// srand(1);
//
// int iRand = rand();
// CString sRand;
// sRand.Format(_T("%2d"), iRand);
CString str;
str.Format(_T("%2d%2d%2d%2d%2d%2d%2d"), nYear,nMonth, nDay,nTime,nMin,nSec,nMinSec);
str.Replace(_T(' '), _T('0'));
精确到毫秒
相关文章推荐
- MYSQL_insert,update,select一体化
- HDU 5446 Unknown Treasure Lucas+中国剩余定理+按位乘
- HDU 5441 Travel 并查集
- HDU 5444 Elven Postman 二叉排序树
- HDU 5438 Ponds dfs模拟
- Gym - 100338C Important Roads 最短路+tarjan
- markdown test
- Gym - 100338E Numbers 贪心
- 集训回顾
- 玩玩,IOS+OpenGL
- qb64手记(2)
- UVALive - 6268 Cycling 贪心
- UVALive - 6266 Admiral 费用流
- UVALive - 6269 Digital Clock 模拟
- Aizu - 2564 Tree Reconstruction 并查集
- android support design widget 学习
- POJ - 3847 Moving to Nuremberg 动归
- Aizu - 2555 Everlasting Zero 模拟
- 简单的设计不简单
- android学习笔记——SQLite简单应用及介绍