郑军学长

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

方法一:

char timebuffer[100];

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

LPSYSTEMTIME lpSystemTime = NULL;

GetLocalTime(lpSystemTime);
sprintf(timebuffer,"[M----,-:-:-]\r\n",
                  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 \n", dbuffer );
 _strtime( tbuffer ); //获取时分秒
 printf( "The current time is %s \n", tbuffer );

 

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

posted on 2017-10-30 14:18  郑军学长  阅读(201)  评论(0编辑  收藏  举报