参照msdn中的实例,你尽情的发挥把。
#include <time.h>
#include <stdio.h>
int main( void )
{
struct tm *newTime;
time_t szClock;
// Get time in seconds
time( &szClock );
// Convert time to struct tm form
newTime = localtime( &szClock );
// Print local time as a string.
printf_s( "Current date and time: %s", asctime( newTime ) ); // C4996
// Note: asctime is deprecated; consider using asctime_s instead
}
结果:
Current date and time: Sun Feb 03 11:38:58 2002
温馨提示:答案为网友推荐,仅供参考