文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>获取精确到毫秒的当前日期时间

获取精确到毫秒的当前日期时间

时间:2011-01-21  来源:pthis

#include <iostream>
#include
<sys/timeb.h>
#include
<time.h>
#include
<stdio.h>

using namespace std;

typedef
char * PCHAR;

void Now(PCHAR buff);

int main()
{
char buff[128];
Now(buff);

cout
<< buff << endl;
return 0;
}

void Now(PCHAR buff)
{
struct timeb tp;
struct tm *tm;

ftime(
&tp);

tm
= localtime(&tp.time);

sprintf(buff,
"%.4d-%.2d-%.2d %.2d:%.2d:%.2d.%.3d",
1900+ tm->tm_year,
1 + tm->tm_mon,
tm
->tm_yday,
tm
->tm_hour,
tm
->tm_min,
tm
->tm_sec,
tp.millitm);

}
相关阅读 更多 +
排行榜 更多 +
龙珠格斗火柴人

龙珠格斗火柴人

飞行射击 下载
荒野恐龙猎手安卓版

荒野恐龙猎手安卓版

飞行射击 下载
超凡坦克英雄

超凡坦克英雄

飞行射击 下载