如何获取当前日期信息?

编程入门 行业动态 更新时间:2024-10-25 12:23:23
本文介绍了如何获取当前日期信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是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.

更多推荐

如何获取当前日期信息?

本文发布于:2023-10-31 07:17:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545408.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   信息

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!