64,674
社区成员
发帖
与我相关
我的任务
分享
time_t M_idata = 13053510;
char sDate[256] ;
struct tm *t_time;
t_time = localtime(&M_idata);
strftime(sDate,256,"%Y-%m-%d ",t_time);
cout<<sDate<<endl;
/**
* Copyright (C), 1988-2010
*
* $Id$
*
* $Log$
*/
#ifndef lint
static const char RCSID[] =
"$Id$";
static const char RELID[] =
"$" "Date: "__FILE__" "__DATE__" "__TIME__" $";
#endif /* not lint */
/**
* @file icmptime.c
* @brief
*/
#include <stdio.h>
#include <time.h>
void icmptime(time_t ms)
{
time_t s, m;
struct tm d;
struct tm t;
char buf[24];
/* 日期部分 */
s = time(0);
d = *localtime(&s);
/* 秒 */
s = ms / 1000;
/* 毫秒 */
m = ms % 1000;
/* 时间部分 */
t = *localtime(&s);
/* 时间日期组合 */
d.tm_hour = t.tm_hour;
d.tm_min = t.tm_min;
d.tm_sec = t.tm_sec;
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &d);
sprintf(buf + 19, ".%03d", (int)m);
printf("%s\n", buf);
}
int
main(int argc, char *argv[])
{
icmptime(13053510);
return 0;
}