获取系统时间

方法一:

char timebuffer[100];

memset(timebuffer,0x00,sizeof(timebuffer));

LPSYSTEMTIME lpSystemTime = NULL;

GetLocalTime(lpSystemTime);
sprintf(timebuffer,"[M----,-:-:-] ",
                  lpSystemTime->wYear,
                  lpSystemTime->wMonth,
                  lpSystemTime->wDay,
                  lpSystemTime->wHour,
                  lpSystemTime->wMinute,
                  lpSystemTime->wSecond);

方法二:

#include <time.h>
char dbuffer [9];
 char tbuffer [9];
 _strdate( dbuffer ); //获取年月日
 printf( "The current date is %s ", dbuffer );
 _strtime( tbuffer ); //获取时分秒
 printf( "The current time is %s ", tbuffer );

http://blog.sina.com.cn/s/blog_70441c8e0100v9cd.html

原文地址:https://www.cnblogs.com/ZHENGJUNupperclassman/p/7754287.html