如何获取当前日期信息? [英] How to get the current date information only?
问题描述
我是C的新手,我需要做一个程序来获取当前日期
信息,没有时间。我的代码在这里:
#include< stdio.h>
#include< time.h>
#include< string.h>
int main()
{
time_t rawtime;
struct tm * timeinfo;
char * t;
rawtime = time(NULL);
timeinfo = localtime( & rawtime);
t = asctime(timeinfo);
printf(t);
返回0;
}
如何只输出t的年,月和日?
I am a newbie of C and I need to do a program to get the current date
information only, without the time. I have my code here:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
char* t;
rawtime = time (NULL);
timeinfo = localtime (&rawtime);
t = asctime(timeinfo);
printf(t);
return 0;
}
How to output only the year, month and day of t?
推荐答案
YiMkiE写道:
YiMkiE wrote:
我是C的新手,我需要做一个程序来获取当前日期
信息,没有时间。我的代码在这里:
#include< stdio.h>
#include< time.h>
#include< string.h>
int main()
{
time_t rawtime;
struct tm * timeinfo;
char * t;
rawtime = time(NULL);
timeinfo = localtime( & rawtime);
t = asctime(timeinfo);
printf(t);
返回0;
}
如何仅输出t的年,月和日?
I am a newbie of C and I need to do a program to get the current date
information only, without the time. I have my code here:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
char* t;
rawtime = time (NULL);
timeinfo = localtime (&rawtime);
t = asctime(timeinfo);
printf(t);
return 0;
}
How to output only the year, month and day of t?
使用适当的''timeinfo''中的字段。
-
Ian Collins。
Use the appropriate fields in ''timeinfo''.
--
Ian Collins.
YiMkiE写道:
YiMkiE wrote:
我是C的新手,我需要做一个程序来获取当前日期
信息,没有时间。我的代码在这里:
#include< stdio.h>
#include< time.h>
#include< string.h>
int main()
{
time_t rawtime;
struct tm * timeinfo;
char * t;
rawtime = time(NULL);
timeinfo = localtime( & rawtime);
t = asctime(timeinfo);
printf(t);
返回0;
}
如何仅输出t的年,月和日?
I am a newbie of C and I need to do a program to get the current date
information only, without the time. I have my code here:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
char* t;
rawtime = time (NULL);
timeinfo = localtime (&rawtime);
t = asctime(timeinfo);
printf(t);
return 0;
}
How to output only the year, month and day of t?
查找strftime函数。
Robert Gamble
Lookup the strftime function.
Robert Gamble
>
你的意思是tm_year?如何参考?
我知道这是一个愚蠢的问题..
Ian Collins?ˉ?é?????
Do you mean the tm_year? How to refer to that?
I know this is a stupid question..
Ian Collins ?ˉ?é?????
YiMkiE写道:
YiMkiE wrote:
我是C的新手,我需要做一个程序来获取当前日期
仅供参考,没有时间。我的代码在这里:
#include< stdio.h>
#include< time.h>
#include< string.h>
int main()
{
time_t rawtime;
struct tm * timeinfo;
char * t;
rawtime = time(NULL);
timeinfo = localtime( & rawtime);
t = asctime(timeinfo);
printf(t);
返回0;
}
如何仅输出t的年,月和日?
I am a newbie of C and I need to do a program to get the current date
information only, without the time. I have my code here:
#include <stdio.h>
#include <time.h>
#include <string.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
char* t;
rawtime = time (NULL);
timeinfo = localtime (&rawtime);
t = asctime(timeinfo);
printf(t);
return 0;
}
How to output only the year, month and day of t?
使用''timeinfo''中的相应字段。
-
Ian科林斯。
Use the appropriate fields in ''timeinfo''.
--
Ian Collins.
这篇关于如何获取当前日期信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!