日期:2014-05-16 浏览次数:20877 次
//这个是vs2008代码
CTime t(1365593408);
CString str=t.Format(L"%Y-%m-%d %H:%M:%S");
str为 2013-04-10 19:30:08
struct tm _tm;
struct tm *tm_now;
time_t timep;
_tm.tm_year = 2013-1900;
_tm.tm_mon = 4-1;
_tm.tm_mday = 10;
_tm.tm_hour = 19;
_tm.tm_min = 30;
_tm.tm_sec = 8;
timep = mktime(&_tm);
tm_now=gmtime(&timep);
printf("%ld\n"timep);//1365589808
#include <stdio.h>
#include <time.h>
int main(int argc, char **argv)
{
struct tm _tm;
struct tm *tm_now;
_tm.tm_year = 2013-1900;
_tm.tm_mon = 4-1;
_tm.tm_mday = 10;
_tm.tm_hour = 19;
_tm.tm_min = 30;
_tm.tm_sec = 8;
time_t timep = mktime(&_tm);
tm_now=localtime(&timep);
printf("%ld\n", timep);
return 0;
}