初学C++,做点小笔记,呵呵。
Code
1 #include <time.h>
2
3 int Main()
4 {
5 char tmpbuf[128];
6 /* 在TZ环境变量中设置时区,如果TZ没有设置,系统采用默认的设置 */
7 //_tzset();
8
9 /* 显示系统时间和日期 */
10 _strtime( tmpbuf );
11 printf( "OS time:\t%s\n", tmpbuf );
12 _strdate( tmpbuf );
13 printf( "OS date:\t%s\n", tmpbuf );
14
15 system("pause");
16 return 0;
17 }Code
1 //Another Mothed Here
2{
3 SYSTEMTIME systime={0};
4 GetLocalTime(&systime);
5 char time[100]={0};
6 sprintf (time,"%04d-%02d-%02d %02d:%02d:%2d:%03d",
7 systime.wYear,
8 systime.wMonth,
9 systime.wDay,
10 systime.wHour,
11 systime.wMinute,
12 systime.wSecond,
13 systime.wMilliseconds);
14 printf("%s",time);
15}