#include "stdafx.h"
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
int main(int argc, _TCHAR* argv[])
{
char s[30];
time_t t=time(0);
struct tm *local = localtime(&t);
strcpy(s,ctime(&t));
printf("local year %d: month %d: day %d: hour %d: min %d:sec %d/n",local->tm_year+1900,local->tm_mon,
local->tm_mday,local->tm_hour,local->tm_min,local->tm_sec);
printf("%s/n",s);
return 0;
}
打印:
local year 2008: month 11: day 5: hour 13: min 47:sec 45
Fri Dec 05 13:47:45 2008