You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nianli/当前时间的获取.c

14 lines
338 B

#include <stdio.h>
#include <time.h>
int main ()
{
time_t t;
struct tm * lt;
time (&t);
lt = localtime (&t);
printf ( "现在是:%d/%d/%d %d:%d:%d\n",lt->tm_year+1900, lt->tm_mon+2, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);
if(lt->tm_mon+1>0&&lt->tm_mon+1<5)
printf("\n夜深了,该睡了");
return 0;
}